You need to sign in to do that
Don't have an account?
Karl Houseknecht 9
lightning:datatable text column will not display currency or boolean fields as text
I am using a lightning:datatable to display the results of a dynamic SOQL query. The columns are generated at runtime from those specified in the query, and default to type: "text". Boolean or currency fields do not display unless you specifically set the type appropriately. This is a problem because it is difficult in many cases to do a describe and get type information beforehand, particularly when querying fields from related objects.
Any insights?
Any insights?
It's ugly but it works. Shouldn't have to do this. Hopefully there's a fix in a later release.
I was able to use currency as field.
You can use data type as 'currency' and it will work for you.Let me know if you still face issue here.Please mark it as best answer if its helpful.
var names= Object.getOwnPropertyNames(returnedResults[0]);
var options = [];
for(var item in names){
var individualPropertyNameObject = {};// Format to be fed to columns of datatable
individualPropertyNameObject.label = returnedResults[0][names[item]];
individualPropertyNameObject.fieldName = names[item];
console.log('type of ' + typeof returnedResults[0][names[item]]);
individualPropertyNameObject.type = typeof returnedResults[0][names[item]] ;
options.push(individualPropertyNameObject);
}
component.set('v.columns',options);
Well there are issues with this method, sometimes it can't detect date as date, but it doesn't return null, anyway it treats them as number and displays. You don't get empty columns