Can I call draw() command after sorting a column?

Can I call draw() command after sorting a column?

adzadz Posts: 7Questions: 5Answers: 0

I want to retain the page number once the columns are sorted. Since a lot of data is being fetched, the sorting/filtering is done at the server side. I noticed the option "full-hold" on https://datatables.net/reference/api/draw() which can be used with the draw(). Where can I call it after the user tries to sort on a column?

The reason that I want to retain the page number after sorting is that I am trying to sort the child rows of all parent rows. The child rows follow the same structure as that of the parent rows. Some columns are only present in the child rows. The corresponding cells in the parent row remain empty. As of now, when I sort by a column specific to the child row, the child rows under the parent are rearranged. This is expected behavior. But the sorting takes me back to the first page. When I sort on these columns, I want the page number to be the same. Is it possible to stay on the same page?

Thanks!

Answers

  • allanallan Posts: 63,815Questions: 1Answers: 10,517 Site admin

    Where can I call it after the user tries to sort on a column?

    You can't. The user sort listener will automatically perform a draw. You would need to remove DataTables default event listeners and bind your own instead if you wanted to change that behaviour.

    Allan

This discussion has been closed.