Created
December 9, 2020 21:28
-
-
Save jeremyvial/8e48dbb0e9f83f237d84756e8b8c8a16 to your computer and use it in GitHub Desktop.
LWC Challenge Component 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public with sharing class CadeauControler { | |
@AuraEnabled(cacheable=true) | |
public static List<Cadeau__c> getCadeauxCreated() { | |
List <Cadeau__c> myCadeaux = new List <Cadeau__c>(); | |
myCadeaux = [SELECT Id, Name, Price__c, CreatedDate, SecretKey__c, publicCible__c | |
FROM Cadeau__c | |
WHERE publicCible__c = 'Enfant' ]; | |
return myCadeaux; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<lightning-card title="List of Christmas gifts for children" icon-name="standard:thanks"> | |
<template if:true={cadeauList}> | |
<lightning-datatable data={cadeauList} columns={columns} key-field="Id"> | |
</lightning-datatable> | |
</template> | |
</lightning-card> | |
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { LightningElement, track, wire } from 'lwc'; | |
import getCadeau from '@salesforce/apex/CadeauControler.getCadeauxCreated'; | |
export default class Component2 extends LightningElement { | |
@track record; | |
@track cadeauList; | |
@track columns = [{ | |
label: 'Gift Name', | |
fieldName: 'Name', | |
type: 'text', | |
sortable: true | |
}, | |
{ | |
label: 'Price', | |
fieldName: 'Price__c', | |
type: 'currency', | |
sortable: true | |
}, | |
{ | |
label: 'Created Date', | |
fieldName: 'CreatedDate', | |
type: 'date', | |
sortable: true | |
}, | |
{ | |
label: 'Age of the child', | |
fieldName: 'publicCible__c', | |
type: 'String', | |
sortable: true | |
} | |
]; | |
// *********************************************** | |
@wire(getCadeau, {}) | |
wireAccount(result){ | |
if (result.data) { | |
this.record = result.data; | |
this.cadeauList = result.data; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment