TransWikia.com

How to add commas in numbers in a HTML table lightning

Salesforce Asked by sfdc on October 4, 2021

I have a lightning component where i have created a table using HTML(tr & td). Everything i am able to achieve . However i am struck formatting the numbers inside the table.

As in the below table i want the numbers 137309 should be displayed as 1,37,709.(All the numbers to have commas accordingly).

enter image description here

Any suggestions in this regards is appreciated

Sample Code:

  <td class="slds-table slds-table_cell-buffer slds-table_bordered slds-table_col-bordered slds-border_left slds-border_right rowclass4">{!prod.F2Actuals} </td>
                        <td class="slds-table slds-table_cell-buffer slds-table_bordered slds-table_col-bordered slds-border_left slds-border_right rowclass4">{!prod.F1Actuals} </td>
                        <td class="slds-table slds-table_cell-buffer slds-table_bordered slds-table_col-bordered slds-border_left slds-border_right rowclass4"> {!prod.FActuals}</td>
                        <td class="slds-table slds-table_cell-buffer slds-table_bordered slds-table_col-bordered slds-border_left slds-border_right rowclass4">{!prod.FActualsYTD}  </td>

One Answer

For currency cell, you could use the lightning:formattedNumber base component to format the numbers as needed:

<lightning:formattedNumber value="{!prod.F2Actuals}"/>

Correct answer by Raul on October 4, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP