Skip to main content
added 172 characters in body
Source Link
sfdcfox
  • 501.7k
  • 21
  • 473
  • 828

There's an example of this in the lwc-recipes repository published by salesforce.com.

Your JS should look like:

import { wire, LightningElement } from 'lwc';
import getAllCompanys from '@salesforce/apex/StockMarketSharesWrapper.getAllCompanys';

export default class MyLwcComponent extends LightningElement {
  @wire(getAllCompanys, {}) companys;
  columns = [{ label: 'Name', fieldName: 'Name' }, { label: 'Ticker', fieldName: 'Ticker' }]
}

And your HTML can look like:

<template>
  <lightning-datatable data={companys.data} columns={columns} key-field="Name">
  </lightning-datatable>
</template>

See also the lightning-datatable documentation.

Edit: Your Apex is reusing the same variable, despite creating new wrappers; this is why most of your data would be blank.

    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' ;

Edit 2: There was a .data missing in the template. I build the entire thing in to a gist.

There's an example of this in the lwc-recipes repository published by salesforce.com.

Your JS should look like:

import { wire, LightningElement } from 'lwc';
import getAllCompanys from '@salesforce/apex/StockMarketSharesWrapper.getAllCompanys';

export default class MyLwcComponent extends LightningElement {
  @wire(getAllCompanys, {}) companys;
  columns = [{ label: 'Name', fieldName: 'Name' }, { label: 'Ticker', fieldName: 'Ticker' }]
}

And your HTML can look like:

<template>
  <lightning-datatable data={companys.data} columns={columns} key-field="Name">
  </lightning-datatable>
</template>

See also the lightning-datatable documentation.

Edit: Your Apex is reusing the same variable, despite creating new wrappers; this is why most of your data would be blank.

    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' ;

There's an example of this in the lwc-recipes repository published by salesforce.com.

Your JS should look like:

import { wire, LightningElement } from 'lwc';
import getAllCompanys from '@salesforce/apex/StockMarketSharesWrapper.getAllCompanys';

export default class MyLwcComponent extends LightningElement {
  @wire(getAllCompanys, {}) companys;
  columns = [{ label: 'Name', fieldName: 'Name' }, { label: 'Ticker', fieldName: 'Ticker' }]
}

And your HTML can look like:

<template>
  <lightning-datatable data={companys.data} columns={columns} key-field="Name">
  </lightning-datatable>
</template>

See also the lightning-datatable documentation.

Edit: Your Apex is reusing the same variable, despite creating new wrappers; this is why most of your data would be blank.

    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' ;

Edit 2: There was a .data missing in the template. I build the entire thing in to a gist.

added 5 characters in body
Source Link
sfdcfox
  • 501.7k
  • 21
  • 473
  • 828

There's an example of this in the lwc-recipes repository published by salesforce.com.

Your JS should look like:

import { wire, LightningElement } from 'lwc';
import getAllCompanys from '@salesforce/apex/StockMarketSharesWrapper.getAllCompanys';

export default class MyLwcComponent extends LightningElement {
  @wire(getAllCompanys, {}) companys;
  columns = [{ label: 'Name', fieldName: 'Name' }, { label: 'Ticker', fieldName: 'Ticker' }]
}

And your HTML can look like:

<template>
  <lightning-datatable data={companys.data} columns={columns} key-field="Name">
  </lightning-datatable>
</template>

See also the lightning-datatable documentation.

Edit: Your Apex is reusing the same variable, despite creating new wrappers; this is why most of your data would be blank.

    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' ;

There's an example of this in the lwc-recipes repository published by salesforce.com.

Your JS should look like:

import { wire, LightningElement } from 'lwc';
import getAllCompanys from '@salesforce/apex/StockMarketSharesWrapper.getAllCompanys';

export default class MyLwcComponent extends LightningElement {
  @wire(getAllCompanys, {}) companys;
  columns = [{ label: 'Name', fieldName: 'Name' }, { label: 'Ticker', fieldName: 'Ticker' }]
}

And your HTML can look like:

<template>
  <lightning-datatable data={companys} columns={columns} key-field="Name">
  </lightning-datatable>
</template>

See also the lightning-datatable documentation.

Edit: Your Apex is reusing the same variable, despite creating new wrappers; this is why most of your data would be blank.

    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' ;

There's an example of this in the lwc-recipes repository published by salesforce.com.

Your JS should look like:

import { wire, LightningElement } from 'lwc';
import getAllCompanys from '@salesforce/apex/StockMarketSharesWrapper.getAllCompanys';

export default class MyLwcComponent extends LightningElement {
  @wire(getAllCompanys, {}) companys;
  columns = [{ label: 'Name', fieldName: 'Name' }, { label: 'Ticker', fieldName: 'Ticker' }]
}

And your HTML can look like:

<template>
  <lightning-datatable data={companys.data} columns={columns} key-field="Name">
  </lightning-datatable>
</template>

See also the lightning-datatable documentation.

Edit: Your Apex is reusing the same variable, despite creating new wrappers; this is why most of your data would be blank.

    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' ;
added 592 characters in body
Source Link
sfdcfox
  • 501.7k
  • 21
  • 473
  • 828

There's an example of this in the lwc-recipes repository published by salesforce.com.

Your JS should look like:

import { wire, LightningElement } from 'lwc';
import getAllCompanys from '@salesforce/apex/StockMarketSharesWrapper.getAllCompanys';

export default class MyLwcComponent extends LightningElement {
  @wire(getAllCompanys, {}) companys;
  columns = [{ label: 'Name', fieldName: 'Name' }, { label: 'Ticker', fieldName: 'Ticker' }]
}

And your HTML can look like:

<template>
  <lightning-datatable data={companys} columns={columns} key-field="Name">
  </lightning-datatable>
</template>

See also the lightning-datatable documentation.

Edit: Your Apex is reusing the same variable, despite creating new wrappers; this is why most of your data would be blank.

    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' ;

There's an example of this in the lwc-recipes repository published by salesforce.com.

Your JS should look like:

import { wire, LightningElement } from 'lwc';
import getAllCompanys from '@salesforce/apex/StockMarketSharesWrapper.getAllCompanys';

export default class MyLwcComponent extends LightningElement {
  @wire(getAllCompanys, {}) companys;
  columns = [{ label: 'Name', fieldName: 'Name' }, { label: 'Ticker', fieldName: 'Ticker' }]
}

And your HTML can look like:

<template>
  <lightning-datatable data={companys} columns={columns} key-field="Name">
  </lightning-datatable>
</template>

See also the lightning-datatable documentation.

There's an example of this in the lwc-recipes repository published by salesforce.com.

Your JS should look like:

import { wire, LightningElement } from 'lwc';
import getAllCompanys from '@salesforce/apex/StockMarketSharesWrapper.getAllCompanys';

export default class MyLwcComponent extends LightningElement {
  @wire(getAllCompanys, {}) companys;
  columns = [{ label: 'Name', fieldName: 'Name' }, { label: 'Ticker', fieldName: 'Ticker' }]
}

And your HTML can look like:

<template>
  <lightning-datatable data={companys} columns={columns} key-field="Name">
  </lightning-datatable>
</template>

See also the lightning-datatable documentation.

Edit: Your Apex is reusing the same variable, despite creating new wrappers; this is why most of your data would be blank.

    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' ;
Source Link
sfdcfox
  • 501.7k
  • 21
  • 473
  • 828
Loading