Sort datatables rows by it's json values

Sort datatables rows by it's json values

krychaj5krychaj5 Posts: 19Questions: 8Answers: 0

Hi!
I'm sorting my datatable by individual buttons (ascending/desceding) and I want to sort it by row data unused in table.

Every button click, I'm getting whole table data, sorting it and reinitialising whole table and it's working perfectly, but after reinitialise I'm losing all previous table filters/selected rows etc which is really annoying.

So my goal is to sort table by nested row data using these buttons WITHOUT destroying/initialising datatable.

Is there any other way to make it "on the fly"?

There is my code with reinitialising: http://live.datatables.net/vufuwali/1/edit?html,js,output

Answers

  • kthorngrenkthorngren Posts: 20,292Questions: 26Answers: 4,768

    The simplest option would be to add that column to the Datatable, hide it and use order() to change the order of the hidden column. For example:
    http://live.datatables.net/pepadepe/1/edit

    This removes the need to destroy the Datatable.

    Kevin

  • krychaj5krychaj5 Posts: 19Questions: 8Answers: 0

    Currently I need to filter data by around 40~ nested values, so it will be not efficient to add & hide that amount of extra columns.

This discussion has been closed.