Orthogonal data and rendering in column def

Orthogonal data and rendering in column def

mihomesmihomes Posts: 128Questions: 13Answers: 0
edited August 26 in DataTables 1.10

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?
                return data.timestamp; //still used for sorting purposes?

This question has an accepted answers - jump to answer


  • kthorngrenkthorngren Posts: 10,723Questions: 25Answers: 2,449
    Answer ✓

    Looks like that would work except for one thing. The data parameter is the columns.data property assigned to the column. In this case it is capture_timestamp. If you want to access other properties in the row data use the row parameter, ie, change return data.display; to return row.display;.


  • mihomesmihomes Posts: 128Questions: 13Answers: 0

    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).

Sign In or Register to comment.