You need to sign in to do that
Don't have an account?
sunny sengar 17
Lighting Component DataTable Columns not display the vlaue
I have a component that is going to be using a <lightning:datatable /> object I am attempting to set the actions with:
fetchAccHelper : function(component, event, helper) {
var actions =[{ label : 'Show Details', name : 'show_details', iconName : 'action:preview'}];
component.set('v.mycolumns', [
// {label: 'CaseNumber', fieldName: 'CaseNumber', type: 'Auto Number'},
{label: 'Case Number', fieldName: 'Case_NumberF__c', type: 'url',sortable: true,filterable: true,typeAttributes: {label: { fieldName: 'Case_NumberF__c'},target: '_blank'}},
{label: 'Subject', fieldName: 'Subject', type: 'text'},
{label: 'Status', fieldName: 'Status', type: 'Picklist'},
{label: 'Created By', fieldName: 'CreatedBy.Name', type: 'Text'},
{label: 'Last Activity', fieldName: 'LastModifiedBy.Name', type: 'Lookup'},
{type:"action", typeAttributes:{ rowActions : actions }}
]);
var action = component.get("c.fetchCase");
action.setParams({
});
action.setCallback(this, function(response){
var state = response.getState();
if (state === "SUCCESS") {
var records =response.getReturnValue();
records.forEach(function(record){
record.show_details = '/'+record.Id;
});
component.set("v.CaseList", response.getReturnValue());
}
});
$A.enqueueAction(action);
},
When I console.log('@@@@@@@@',response.getReturnValue()); from my call back function I do see that I am getting the apropreate and expected resluts from my controller, however my lighting datatabel is displaying Case Number, Subject, Status Fields, but CreatedBy and LastModifiedBy fields value does not showing.
Any help would be much apreciated!Thanks
fetchAccHelper : function(component, event, helper) {
var actions =[{ label : 'Show Details', name : 'show_details', iconName : 'action:preview'}];
component.set('v.mycolumns', [
// {label: 'CaseNumber', fieldName: 'CaseNumber', type: 'Auto Number'},
{label: 'Case Number', fieldName: 'Case_NumberF__c', type: 'url',sortable: true,filterable: true,typeAttributes: {label: { fieldName: 'Case_NumberF__c'},target: '_blank'}},
{label: 'Subject', fieldName: 'Subject', type: 'text'},
{label: 'Status', fieldName: 'Status', type: 'Picklist'},
{label: 'Created By', fieldName: 'CreatedBy.Name', type: 'Text'},
{label: 'Last Activity', fieldName: 'LastModifiedBy.Name', type: 'Lookup'},
{type:"action", typeAttributes:{ rowActions : actions }}
]);
var action = component.get("c.fetchCase");
action.setParams({
});
action.setCallback(this, function(response){
var state = response.getState();
if (state === "SUCCESS") {
var records =response.getReturnValue();
records.forEach(function(record){
record.show_details = '/'+record.Id;
});
component.set("v.CaseList", response.getReturnValue());
}
});
$A.enqueueAction(action);
},
When I console.log('@@@@@@@@',response.getReturnValue()); from my call back function I do see that I am getting the apropreate and expected resluts from my controller, however my lighting datatabel is displaying Case Number, Subject, Status Fields, but CreatedBy and LastModifiedBy fields value does not showing.
Any help would be much apreciated!Thanks
As mentioned can you try checking if { label: 'Created By', fieldName: 'CreatedBy', type: 'text' }, this works?
As present in the below code can you try if you modify your if(state=="success") part to fit the below snippet as I think they are setting the value again after getting the records:
Below is the whole snippet for quick reference:
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
All Answers
Can you check if you are passing the correct soql results that have the necessary details if so I would suggest you to check the lightning:datatable tag.
For reference, I am placing the tag below so that you can try checking it:
reference: https://developer.salesforce.com/docs/component-library/bundle/lightning:datatable/example
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
did you add createdBy.Name,lastModifiedBy.Name these fields in your query. if you didn't add then add and check again.
For Example : SELECT Id, Status,createdBy.Name,lastModifiedBy.Name FROM Case limit 5
let me know if it helps you and marking it as best.
Thank You
But i Checked Lightning datatable tag is correct, When i pass 'filedName: CreatedById' instead of 'filedName: CreatedBy.Name' Then Received the response in datatable.
I have add createdBy.Name,lastModifiedBy.Name in Soql query, But In datatable CreatedBy field i received ID. But i need Profile Name.
As mentioned can you try checking if { label: 'Created By', fieldName: 'CreatedBy', type: 'text' }, this works?
As present in the below code can you try if you modify your if(state=="success") part to fit the below snippet as I think they are setting the value again after getting the records:
Below is the whole snippet for quick reference:
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
and
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.