How to get two comma's for 7 digits number

How to get two comma's for 7 digits number

Saritha Saritha Posts: 23Questions: 7Answers: 1

I have the column value as "1500,000".I am able populate the one comma after 3 digits from the last but this column value is contained 7 digits so i wanted to populate the another comma at another 3 digits before. like "1,500,000".Please let me know how can i achieve this.It's really need.

Answers

  • Saritha Saritha Posts: 23Questions: 7Answers: 1
          "aTargets": [ 11 ],
                    "mRender": function (data, type, full) {
                     var formmatedvalue=data.replace(/(\d+)(\d{3})/, '$1' + ',' + '$2')//How to format here for 3 digitis later gain with comma
                      return formmatedvalue;
                       }
              }], 
    
  • Saritha Saritha Posts: 23Questions: 7Answers: 1

    I got the solution
    var formmatedvalue=data.replace(/\B(?=(\d{3})+(?!\d))/g, ",")//need to replace the format.

  • allanallan Posts: 63,814Questions: 1Answers: 10,517 Site admin

    Possibly an easier solution would be to use the built in number renderer type.

    Allan

This discussion has been closed.