Can't sort on a column, can't figure out why, no errors/warnings thrown.

Can't sort on a column, can't figure out why, no errors/warnings thrown.

gauzegauze Posts: 6Questions: 2Answers: 0

Link to test case: can't link to test case

Debugger code (debug.datatables.net):
ivadoc

Error messages shown:
none
Description of problem:
I have an issue where I am loading a table with different data depending on some options (but all the data is the same format), and one column "Status" which contains an HTML Select (dropdown menu) element and currently all pages work with sorting on this column except one and I get no errors so I'm kinda stuck right now as to what to do. Help?

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 19,922Questions: 26Answers: 4,696

    Without seeing the problem and the data that is not being sorted its hard to say what the problem might be. If you are using server side processing, ie serverSide: true, then the problem will be with the server script.

    If not using server side processing then please build a simple test case with an example of the data that isn't being sorted so we can help debug.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • gauzegauze Posts: 6Questions: 2Answers: 0

    ok, I'm working on it, thank you.

  • gauzegauze Posts: 6Questions: 2Answers: 0

    ok here's my cut down example, it sorts on every other column except "Status" http://entropy.tmok.com/~gauze/toast.html

    I've stripped out the rest of the data and a bunch of javascript but it still doesn't work on this page. I fixed up the code to not return any errors or warnings from W3 HTML validator (and another one) just to eliminate that. Tested with current Firefox and Chromium on Linux and Chrome on Mac.

  • colincolin Posts: 15,094Questions: 1Answers: 2,581
    Answer ✓

    Because it's a select element, you need to get the current value of that element to be used in the sorting. Kevin's example here, from a different thread, is doing something similar but for input elements. That should get you going in the right direction,

    Colin

  • gauzegauze Posts: 6Questions: 2Answers: 0

    ~~ok I checked that example and wound up looking around at what some of the lines of code did that I didn't understand and I stumbled across

    https://cdn.datatables.net/plug-ins/1.13.6/sorting/custom-data-source/dom-select.js

    which is basically the same bit of code as the
    $.fn.dataTable.ext.order['dom-text'] but for select elements

    and added

    {"orderDataType": "dom-select", "targets": [ -3 ] },

    to my columnDefs for that table and voila.

    thanks. ~~

  • kthorngrenkthorngren Posts: 19,922Questions: 26Answers: 4,696

    Glad you got it working. See this Live DOM ordering example for examples of sorting different types of inputs.

    Kevin

Sign In or Register to comment.