Created
August 16, 2020 18:58
-
-
Save dhaniksahni/1d11a2c52eb0546d88743278bde0351e to your computer and use it in GitHub Desktop.
LWC DataTable
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> | |
<template if:true={contact}> | |
<lightning-datatable key-field="Id" | |
data={contact} | |
columns={columns}> | |
</lightning-datatable> | |
</template> | |
</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, wire } from 'lwc'; | |
import getContactList from '@salesforce/apex/ContactController.getContactList'; | |
import { ShowToastEvent } from 'lightning/platformShowToastEvent'; | |
const columns = [ | |
{ label: 'First Name', fieldName: 'FirstName' }, | |
{ label: 'Last Name', fieldName: 'LastName' }, | |
{ label: 'Title', fieldName: 'Title' }, | |
{ label: 'Phone', fieldName: 'Phone', type: 'phone' }, | |
{ label: 'Email', fieldName: 'Email', type: 'email' } | |
]; | |
export default class SingleSelectDatatable extends LightningElement { | |
error; | |
columns = columns; | |
contact=[]; | |
connectedCallback() | |
{ | |
getContactList() | |
.then((result,error) => { | |
if (result) { | |
this.contact=result; | |
} else if (error) { | |
console.error(error); | |
} | |
}) | |
} | |
} |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata"> | |
<apiVersion>49.0</apiVersion> | |
<isExposed>true</isExposed> | |
<targets> | |
<target>lightningCommunity__Page</target> | |
<target>lightningCommunity__Default</target> | |
<target>lightning__RecordPage</target> | |
<target>lightning__AppPage</target> | |
<target>lightning__HomePage</target> | |
<target>lightning__Tab</target> | |
</targets> | |
</LightningComponentBundle> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment