Orthogonal data - custom display, filter and sort breaks multiordering.

Orthogonal data - custom display, filter and sort breaks multiordering.

vibonaccivibonacci Posts: 4Questions: 2Answers: 0

Hi,

I have a column that use different values for display, filter and sort in the column render function. After some time, I got the correct different values for display, filter and sort and they all work nicely!

For some reason, the multi ordering is broken due to this function. I have another column 0, which is just a simple id integer, which does not sort properly when it is sorted on secondly.

        columns: [
            { name: 'id', data: 'id'}, //just an int

            { name: 'enddate', "render":
                    function ( data, type, row) {
                        switch (type) {
                            //If display, return formatted data
                            case 'display':
                                    return '<div>' + row.endDate + '</div><div class="subrow">' + row.endTime + '</div>'
                                }
                            //If filter, return endDate and endTime unformatted so HTML tags do not pollute it
                            case 'filter':
                                return row.endDate + ' ' + row.endTime;
                            //If sort or type, use endDateTimeUnix
                            default:
                                return row.endDateTimeUnix;
                        }
                    }
            },

The problem:

order: [[ 1, 'desc' ]],

works.

order: [[ 1, 'desc' ], [ 0, 'asc' ]],

does not. The same problem arises when I use shift click, which is probably the same as the above. The multi order did work before I used the 'complex' render function for enddate.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,353Questions: 26Answers: 4,776

    Can you build a test case showing the issue with an example of your data? Its hard to say with just the code.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • vibonaccivibonacci Posts: 4Questions: 2Answers: 0

    All right. As you can see, after first sorting on date and then shift clicking id, the multi sorting does not work properly.

    http://live.datatables.net/pitevesa/7/edit?html,js,output

  • kthorngrenkthorngren Posts: 20,353Questions: 26Answers: 4,776
    edited May 2018 Answer ✓

    Thanks for the example. Based on your example I'm not sure what you are expecting. I updated the example by adding a duplicate set of rows changing only the ID.
    http://live.datatables.net/pabedoyu/1/edit

    Now if you sort the Date then shift click to sort the ID it seems to work correctly for me. The Dates are sorted then the IDs are sorted within the groups (matching) of Dates (if that makes sense).

    Maybe you can describe what you are expecting.

    Kevin

  • vibonaccivibonacci Posts: 4Questions: 2Answers: 0

    Nvm. I just realized I had a horrible brainfart :'( . It indeed works as intended. Thx for the help though,

  • kthorngrenkthorngren Posts: 20,353Questions: 26Answers: 4,776

    That's ok. It took me a bit of messing around to understand how multi-sort works at first :smile:

    Kevin

This discussion has been closed.