Orthogonal data and rendering in column def

Orthogonal data and rendering in column def

mihomesmihomes Posts: 165Questions: 23Answers: 0
edited August 2020 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?
            default:
                return data.timestamp; //still used for sorting purposes?
        }
    } 
},

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951
    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;.

    Kevin

  • mihomesmihomes Posts: 165Questions: 23Answers: 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).

This discussion has been closed.