function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Abhishek Pandey 180Abhishek Pandey 180 

relation in Lightning data table

{ label: 'Hospital', fieldName: 'Hospital__r', type: 'Name' },
  { label: 'Material number', fieldName: 'Product__r.Mtrl_nbr__c', type: 'Text' },
 { label: 'Product', fieldName: 'Product__r.Name', type: 'Text' }

I am getting blank values in the above field in the lightning data table. Pls help how to show the relation in lightning data table
Maharajan CMaharajan C
Hi Abhishek,

You have to handle it via javascript:

Change the column as :    
{ label: 'Material number', fieldName: 'ProductMtrlnbr', type: 'Text' },
{ label: 'Product', fieldName: 'ProductName', type: 'Text' }
if (state === "SUCCESS") {
    var rows = response.getReturnValue();
    for (var i = 0; i < rows.length; i++) {
        var row = rows[i];
        if (row.Product__c) 
        {
            row.ProductName = row.Product__r.Name;
            row.ProductMtrlnbr = row.Product__r.Mtrl_nbr__c;
        }
    }
    cmp.set('v.mydata', rows);
}

https://www.salesforcecodecrack.com/2019/06/display-reference-parent-fields-data.html

https://salesforce.stackexchange.com/questions/200761/parent-field-in-lightning-datatable

Thanks,
Maharajan.C