0

I have lightning data table with one of the columns associated to Amount field. I want amount values to appear with '$' symbol for which I declared Amount column with type 'Currency' but I was not able to see amount values with '$' or any other currency symbol. As a workaround, I converted the data type of Amount to String and concatenated the '$' symbol :

Column Declaration : const columns = [{ fieldName: "Amount", hideDefaultActions: true, label: "AMOUNT", type: "String", sortable: "true" }];

Evaluation of Amount value : rowData.Amount = "$" + (((obj.amount / 100) + '').indexOf('.') == -1 ? (obj.amount / 100) + '.00' : (obj.amount / 100));

But with this workaround, sorting on Amount field is not working as expected. I am using following code for sorting : enter image description here

Lightning Datatable html part :

enter image description here

I need both sorting and display of amount values with currency symbol to be working correctly. Any help would be highly appreciated.

  • it will be "currency" not "Currency" JS in case sensitive – User6670 Jul 28 '20 at 5:25
0

Use currency with small 'c' as the datatype, you would get the symbol.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.