How can I order column by a value passed to data instead of custom rendered content?
What I have done
I use jquery datatables to display data. From server to client I pass numeric data only. On client side i create table content using custom render functions:
{
"targets": [9],
"visible": true,
"searchable": true,
"render": function(data, type, row) {
if (row[9] == -2) {
return '';
}
if (row[9] == -1) {
return '<img width="20px" src="/~home/www/images/loader.gif" />';
}
var result = row[9];
if (row[10] > 0) {
result += '<strong><span class="text-success">';
result += '(+' + row[10] + ')';
result += '</span></strong>';
}
if (row[10] < 0) {
result += '<strong><span class="text-danger">';
result += '(' + row[10] + ')';
result += '</span></strong>';
}
return result;
},
},
{
"targets": [10, 11],
"visible": false,
"searchable": false,
},
Even through columns 9,10 and 11 contain only numeric values. Column 9 is ordered as string based on string values generated by provided JS function.
How instruct datatables to order by original 'row[9]', but keep custom rendered content in cells?