SORT COLUMN NUMBER
SORT COLUMN NUMBER
Hello,
I have this code for a column:
[code]
{
"mData": "credito_restante",
"sDefaultContent": "",
"bSortable": true,
"mRender": function (val, type, row) {
var sReturn = "" + val + "";
return sReturn;
}
},
[/code]
But when I sort by this column, it sorts as a text, not as a number.
I try this:
sType: numeric
But not works, Any idea please??
Thank you!
I have this code for a column:
[code]
{
"mData": "credito_restante",
"sDefaultContent": "",
"bSortable": true,
"mRender": function (val, type, row) {
var sReturn = "" + val + "";
return sReturn;
}
},
[/code]
But when I sort by this column, it sorts as a text, not as a number.
I try this:
sType: numeric
But not works, Any idea please??
Thank you!
This discussion has been closed.
Replies
http://stackoverflow.com/questions/11341379/datatables-sorts-strings-instead-of-numeric
Thanks!
[code]
"mRender": function (val, type, row) {
if ( type === 'display' ) {
return "" + val + "";
}
return val;
}
[/code]
i.e. for the `display` type it will use your markup, otherwise it uses the plain value (for sort, type checking and filter). See: http://datatables.net/blog/Orthogonal_data for more information.
Allan