data-order not work using Ajax datasource
data-order not work using Ajax datasource
I'm trying to set the correct sorting value for a date column.
My table is populated via ajax. The datasource contains 2 values for date field: one to be displayed and formatted depending by the UI language (field:SendDate), and one to be used by datatables for ordering the column (field: DataOrder).
I've tried to use the 'data-order' attribute in the follwing way:
{
"targets": 2,
"createdCell": function (td, cellData, rowData, row, col) {
$(td).attr("data-order", rowData.DataOrder);
}
}
but it doesn't work.
I've tried setting sort property like in this post
{
"data": {
type: '@data-order',
sort: '@data-order'
},
var rclass = "read";
if (tipoRecord === 'R')
rclass = data.Letto ? "read" : "toread";
return "<div class='font-size-sm line-height-1 " + rclass + "'>" + data.SendDate + "</div>";
}
},
but throw the error Cannot read property 'SendDate' of undefined.
How can I set the correct order for this column?
Thanks
Edika
Answers
Switching for type in render method do the trick