Filtering and display get the rendered string
Filtering and display get the rendered string

I don't understand what is going on in line 5 in one of the examples posted: https://editor.datatables.net/examples/plug-ins/fieldPlugin.html
Since this is for the DataTabe, I guess I am confused as to when type would not be 'display' and the zero or one would be displayed instead of ToDo/Done
{
className: "center",
data: "done",
render: function (data, type, row) {
if ( type === 'display' || type === 'filter' ) {
// Filtering and display get the rendered string
return data == 0 ? "To do" : "Done";
}
// Otherwise just give the original data
return data;
}
}
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Orthogonal data is explained in this doc:
https://datatables.net/manual/data/orthogonal-data
To visualize this put
console.log( type )
between lines 4 and 5. On table load you will see the render function is run fordisplay
andfilter
. If you then sort the column you will see it run for thesort
operation. You can also use the render function for the export buttons as shown in this example.So basically the above results in displaying
Done
orToDo
. Also you can filter the table by typingDone
orToDo
instead of0
or1
. But the sorting is performed using0
and1
instead of the words.Does this help?
Kevin
awesome explanation. thank you.