[SalesForce] How to get Reference field value for lightning:datatable data attribute

I'm creating the lightning:datatable dynamically and passing the data by querying from contact object, and I have a parent Account.name field in the SOQL query and I have specified the field Account.Name with type reference in the columns attribute but account name value is not populating, it's displaying only the AccountId, but it should display Account Name, is there any possibility to display the Reference field value not exactly sfdc record id.

$A.createComponent(
 "lightning:datatable",
 {   
    'aura:id': 'dynamicChild',
    'data': component.get('v.all'),
    'columns': component.get('v.tColumns'),
    'hideCheckboxColumn': 'true',
    'keyField': 'Id',
    'minColumnWidth': 5,
    'maxColumnWidth': 10,
    'sortedDirection': 'asc'
 },
 function(datatable){
    if (component.isValid())
        tab.set('v.body', datatable);
    else throw new Error(error);
 });

Thanks in advance.

Best Answer

This cannot be done straight from the object that you get from apex - you will need to flatten the object that you get - see my question about the exact same issue here:

Winter 18 does not get values from a parent record

There is an answer there on how to flatten the records