regex - How to round to 2 decimal places in jquery datatable? -


i using jquery datatable aocolumns round specific columns 2 decimal places seems unable correct regular expression or may wrong logic.

"aocolumndefs": [ {                         "atargets": [ 7 ],                         "mrender": function (data, type, full) {                             var formmatedvalue = data.replace(/\d+(\.\d{1,2})?/, "")                              return formmatedvalue;                         }                     }], 

the output column should be

120.02 1560.56 565645.25 124995.89 etc ..... 

any possible solution this?

use function:

function (data, type, full) {      return data.tostring().match(/\d+(\.\d{1,2})?/g)[0]; } 

you looking matching part need , not replace.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -