I have a datatable with a currency column. My column definition is:
summaryDataColumns = [
{
type: "text",
label: "Summary",
fieldName: "sumName"
},
{
type: "text",
label: "Taxes",
fieldName: "taxName",
hideDefaultActions: true
},
{
type: "currency",
label: "",
fieldName: "subtotal",
hideDefaultActions: true,
typeAttributes: {
currencyCode: "USD"
}
}
];
the currency column shows something like USD 300.00
. I need to show the currency symbol instead of the currency code. Something like $ 300.00
is what I need. How do you do it?
update Oct 20: my updated columns definition is:
summaryDataColumns = [
{
type: "text",
label: "Summary",
fieldName: "sumName"
},
{
type: "text",
label: "Taxes",
fieldName: "taxName",
hideDefaultActions: true
},
{
type: "currency",
label: "",
fieldName: "subtotal",
hideDefaultActions: true,
typeAttributes: {
currencyCode: "USD",
currencyDisplayAs: "symbol"
}
}
];
however, it does not seem to make any difference in the lwc datatable. 3 letter code still showing up:
Best Answer
To display the value as $ num instead of USD num, include
currencyDisplayAs: "symbol"
in thetypeAttributes
.For more details on data table type attributes, refer to Formatting with Data Types section here.
Ref screenshot for USD formatted display: