1

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: enter image description here

2
  • Does it allow you to change the currency code line to a $? I.e. changing currencyCode: "USD" to currencyCode: "$"?
    – Instread
    Commented Oct 20, 2020 at 0:47
  • @Instread no, it does not accept $. It throws an error
    – dev4life
    Commented Oct 20, 2020 at 14:45

1 Answer 1

1

To display the value as $ num instead of USD num, include currencyDisplayAs: "symbol" in the typeAttributes.

For more details on data table type attributes, refer to Formatting with Data Types section here.


Ref screenshot for USD formatted display:

enter image description here

8
  • It is still showing the 3-letter code...
    – dev4life
    Commented Oct 20, 2020 at 14:36
  • Did you mean it is showing US$ or USD? Could you post the updated code (and provide screenshot)?
    – arut
    Commented Oct 20, 2020 at 16:00
  • I need to show "$ 000" instead of "USD 000". I am not sure it this has to do with multi currency being disabled
    – dev4life
    Commented Oct 20, 2020 at 16:20
  • Multi-currency settings could be a factor, although I have not verified that at my end. But, after including the currencyDisplayAs type attribute, it should definitely not show up as USD (and I have verified this in my dev org). I'm assuming that you have refreshed the page (with clearing cache) or tried it in a different browser.
    – arut
    Commented Oct 20, 2020 at 16:24
  • Yes, I have cleared cache and reloaded 3 times the page. The changes in the code are there, but table still shows 3-letter currency code. I wonder, does your dev org have multi currency enabled?
    – dev4life
    Commented Oct 20, 2020 at 16:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .