Sorting via javascript only working the first time

Sorting via javascript only working the first time

alex57alex57 Posts: 1Questions: 1Answers: 0

Hello,

I am using version 1.10.16 of datatables and have a static table with the following initialiser:

        var mappingTable = $('#importMappings').DataTable({
            "paging": false,
            "info": false,
            "searching": false, 
            "ordering": true
        });

The table renders fine with no console errors. Below is my multi column sort:

mappingTable.order([[4, 'desc'], [0, 'asc']]).draw();

This sort order is applied when a drop down in a row is changed. This changes switches the value in the column relating to the [4, 'desc'] to either a 1 or 0 in a <td> programmatically for the same row. The ordering after the data value switch works the first time but if I then programmatically switch the 1 or 0 back again causing the reorder to re-fire the sorting doesn't work at all. There are no console errors. I have tried draw() with various parameters and the effect is the same. Am I missing something?

Thanks in advance.

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    Hi @alex57 ,

    Everything looks like it should work. We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.