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
Post a Comment