reorder an initialized table

reorder an initialized table

TeroaTeroa Posts: 9Questions: 3Answers: 0

Hi there,

I've got an easy table with some dates and names.
There is an event to add a new row from another script. Am I able to reorder the current datatable after the new row was appended? Or do I have to re-initialize the table?

Something like $('#table1').DataTable().order()

Answers

  • kthorngrenkthorngren Posts: 21,301Questions: 26Answers: 4,946

    If you us a Datatables API like row.add() to add the row Datatables will updated the sorting automatically. If you add the row using Javascript then you will need to have Datatables update its data cache by using something like rows().invalidate(). The preferred is to use Datatables APIs to add or update rows instead of using the invalidate methods.

    Kevin

  • TeroaTeroa Posts: 9Questions: 3Answers: 0

    hello kthorngren,

    thank you very much. I will test the add-api, if it's fitting my needs, then I will use it. If not I will try to invalidate().

This discussion has been closed.