how to keep current page after sorting?

how to keep current page after sorting?

x48rayx48ray Posts: 3Questions: 1Answers: 0

I'm using http://www.datatables.net version 1.9.4. After sorting I want to keep the current page but default behavior redirects me to the first page. Is it possible to configure? If not could you provide me with some solution. Thanks

Answers

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    I don't understand. If you are currently on, say, page 35, and then do a sort, what would be the significance of page 35 in the new order?

  • x48rayx48ray Posts: 3Questions: 1Answers: 0

    that's the customer requirement

  • allanallan Posts: 63,237Questions: 1Answers: 10,418 Site admin

    There is no option for it in DataTables 1.9. In 1.10 you can use draw() setting the optional reset parameter to false - http://live.datatables.net/pisuvet/1/edit .

    However, I agree with tangerine, the data on page 35 is meaningless to the end user after it has been sorted.

    Allan

  • x48rayx48ray Posts: 3Questions: 1Answers: 0

    The example http://live.datatables.net/pisuvet/1/edit here doesn't work.
    Required behavior:
    1. Go to page 4.
    2. Sort by some column.
    3. After sorting I should stay on page 4

    http://screencast.com/t/4JodEbmnAf

  • allanallan Posts: 63,237Questions: 1Answers: 10,418 Site admin

    In what way does it not do that? The API calls you can see in the code are taking it to page 4, then applying a sort on column 3 three, and then doing a draw. It is still on page 4, like you requested.

    If you mean the click on the header to trigger sort, then yes, that will always jump you back to the first page, there is no way around that without modifying DataTables, or applying your own sort / click listener to the header elements.

    Allan

This discussion has been closed.