Is there a way to format numbers without knowing column indices ahead of time?
Is there a way to format numbers without knowing column indices ahead of time?

I'm relatively new to DataTables and having trouble determining if it's possible to render all unformatted numbers to comma delimeted format (e.g. 1000000 -> 1,000,000) without knowing the table layout before hand. The reason I ask is because I'm using datatables to show the results of a number of different user selected queries and writing custom formats for each different query would be very tedious.
Thanks!
Thanks!
This discussion has been closed.
Replies
Allan
[code]
var colDefs = [
{
"aTargets": [0 ... N],
"mRender": function (data, type, row) {
if (type === 'display') {
return format(data);
}
else if (type === 'filter') {
return data + ' ' + format(data);
}
return data;
}
}
];
[/code]
Is there a value that can be assigned to aTargets to have it affect all columns?
Yes `"_all"` would do it. But I worry it might be a little slow depending on how much data you have.
Here is an example using aTargets with a class: http://live.datatables.net/uqugik/edit#javascript,html
Allan