CAUSE
Studying the source code for DataTables, it seems that HTML5 attributes are data-only read during table initialization and only for static data.
Decision
Decision No. 1
, . . .
, , :
{
"name": "Tiger Nixon",
"position": "System Architect",
"salary": "$3,120",
"start_date": {
"display": "Mon 25th Apr 11",
"timestamp": "1303682400"
},
"office": "Edinburgh",
"extn": "5421"
}
DataTables :
$(document).ready(function() {
$('#example').dataTable( {
ajax: "data/orthogonal.txt",
columns: [
{ data: "name" },
{ data: "position" },
{ data: "office" },
{ data: "extn" },
{ data: {
_: "start_date.display",
sort: "start_date.timestamp"
} },
{ data: "salary" }
]
} );
} );
start_data.display , start_data.timestamp .
№2
columns.render , :
$('#example').dataTable({
"columnDefs": [{
"targets": 6,
"data": "field_name",
"render": function (data, type, full, meta) {
if(type === 'sort'){
if(data === "Ej fakturerad") {
data = 1;
} else if(data === "Nej") {
data = 2;
} else if(data === "Kredit") {
data = 3;
} else if(data === "Ja") {
data = 4;
}
}
return data;
}
}]
});