Skip to content

Instantly share code, notes, and snippets.

@brianmfear
Created December 16, 2021 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianmfear/7de4205525e15f1bcd7b3fabf32f1e60 to your computer and use it in GitHub Desktop.
Save brianmfear/7de4205525e15f1bcd7b3fabf32f1e60 to your computer and use it in GitHub Desktop.
Download this as a ZIP file, move the files so they line up in the proper places, then deploy.
force-app/main/default/classes/StockMarketSharesWrapper.cls
force-app/main/default/classes/StockMarketSharesWrapper.cls-meta.xml
force-app/main/default/lwc/wrapperList/wrapperList.html
force-app/main/default/lwc/wrapperList/wrapperList.js
force-app/main/default/lwc/wrapperList/wrapperList.js-meta.xml
Support for question https://salesforce.stackexchange.com/q/365372/2984
public with sharing class StockMarketSharesWrapper {
@AuraEnabled(cacheable=true)
public static List<Wrapper> getAllCompanys(){
// Define the list
List<Wrapper> com = new List<Wrapper>();
// Create account sObjects
Wrapper w = new Wrapper();
w.Ticker = 'U';
w.Name = 'Unity Software Inc';
Wrapper w1 = new Wrapper();
w1.Ticker = 'UAL';
w1.Name = 'United Airlines Holdings, Inc.' ;
Wrapper w2 = new Wrapper();
w2.Ticker ='DAOOU' ;
w2.Name = 'Crypto 1 Acquisition Corp Unit';
Wrapper w3 = new Wrapper();
w3.Ticker = 'GLLIU';
w3.Name ='Globalink Investment Inc. Unit' ;
// Add accounts to the list
com.add(w);
com.add(w1);
com.add(w2);
com.add(w3);
return com;
}
public class Wrapper{
@AuraEnabled
public String Name {get; set;}
@AuraEnabled
public String Ticker {get; set;}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>52.0</apiVersion>
<status>Active</status>
</ApexClass>
<template>
<lightning-datatable data={companys.data} columns={columns} key-field="Name">
</lightning-datatable>
<lightning-button label="Show Data" onclick={showData}></lightning-button>
</template>
import { wire, LightningElement } from 'lwc';
import getAllCompanys from '@salesforce/apex/StockMarketSharesWrapper.getAllCompanys';
export default class WrapperList extends LightningElement {
@wire(getAllCompanys, {}) companys;
columns = [{ label: 'Name', fieldName: 'Name' }, { label: 'Ticker', fieldName: 'Ticker' }]
}
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>52.0</apiVersion>
<isExposed>false</isExposed>
</LightningComponentBundle>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment