Orthogonal data and rendering in column def
Orthogonal data and rendering in column def
Never used orthogonal data before with datatables until now. I originally was using the commented out portion which worked as expected - the display value was used for displaying and the timestamp value was used for sorting. Now, I have a need to modify the output displayed while still using 'timestamp' for sorting.
Will this achieve the same as what is commented out just allowing me to edit the 'display version' of the data?
{
"data": 'capture_timestamp',
//"render": {
// _: 'display',
// sort: 'timestamp'
//}
"render": function ( data, type, row ) {
switch (type) {
case 'display':
return data.display; //modify return as needed for display only?
default:
return data.timestamp; //still used for sorting purposes?
}
}
},
This question has an accepted answers - jump to answer
Answers
Looks like that would work except for one thing. The
data
parameter is thecolumns.data
property assigned to the column. In this case it iscapture_timestamp
. If you want to access other properties in the row data use therow
parameter, ie, changereturn data.display;
toreturn row.display;
.Kevin
Thanks for clearing that up. In the end because I used the switch statement I didn't need to send orthogonal data from server side, but still needed to sort and display differently which this handles (just using
data
for each).