public class LightningDataTableController{
@AuraEnabled
public static List<Contact> fetchAccountContacts(String accountId) {
List<Contact> lstContact=new List<Contact>();
lstContact=[select id ,Name,Email,Phone from contact where accountid=:accountId];
return lstContact;
}
}
({
doInit : function(component, event){
var contactAction = component.get("c.fetchAccountContacts");
contactAction.setParams({
accountId : component.get("v.recordId")
});
contactAction.setCallback(this,function(response){
var state = response.getState();
if (state === "SUCCESS" && response.getReturnValue() != '') {
var records =response.getReturnValue();
records.forEach(function(record){
record.LinkName = '/'+record.Id;
});
component.set('v.data',response.getReturnValue());
}else if(state === "ERROR"){
console.log('A problem occurred: ' + JSON.stringify(response.error));
}
});
$A.enqueueAction(contactAction);
}
})
Lightning DataTable : Lightning Web Component
LightningDataTableController(Apex Controller )
public class LightningDataTableController{
@AuraEnabled(cacheable=true)
public static List<Contact> fetchAccountContacts(String contactId) {
List<Contact> lstContact=new List<Contact>();
lstContact=[select id ,Name,Email,Phone from contact where accountid=:contactId];
return lstContact;
}
}
Lightning Datatable with Mask and Unmasked Description : lightning-datatable displays tabular data where each cell with field values and value should be masked and unmasked. ADVANCED OPTIONS FOR lightning-datatable IN LWC : Component HTML Component JS import { LightningElement, track, api } from 'lwc'; import getContacts from '@salesforce/apex/ContactController.getContacts'; export default class MaskComp extends LightningElement { @track accounts; @api recordId; columns = [ { label: 'First Name', fieldName: 'FirstName', type: 'text' }, { label: 'Last Name', fieldName: 'LastName', type: 'text' }, { label: 'Email', fieldName: 'maskedEmail', type: 'button', ...
Comments
Post a Comment