Need help with columns that ignore sort

Need help with columns that ignore sort

SAC_DatatablesSAC_Datatables Posts: 4Questions: 2Answers: 0

I have a table with multiple columns several of which use the render option to display descriptive text rather than a record ID. All of these columns (Advisor, School, and Citizenship in the example) will not sort. When you click on the header the sort indicator changes but nothing else changes.

If I remove type === "sort" then the columns will sort by the associated record ID.

Any insights would be appreciated.

The column definitions all follow the same format:

{
    data: "StudentInfo.Advisor",
    render: function (val, type, row) {
        if (type === "display" || type === "filter" || type === "sort") {
            return row.Teachers.LastName ?
                row.Teachers.LastName + ", " + row.Teachers.FirstName :
                val
        }
        return val;
    }
},

A working example can be found on JSFiddle.net: https://jsfiddle.net/rfayle/cj4vLqnd/

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,142Questions: 1Answers: 2,586
    Answer ✓

    Hi @SAC_Datatables ,

    See this fiddle here - I've changed the Advisor column so that it now works. The problem was that you were returning the modified string for all types of type, except the one that does the column type detection (which is type - too many types in that last sentence!). By always returning the modified string for all types, everything works as expected.

    Cheers,

    Colin

This discussion has been closed.