SearchPanes, How to mantain current page after rebuildPane is used?

SearchPanes, How to mantain current page after rebuildPane is used?

DreakerDreaker Posts: 13Questions: 6Answers: 0

Whenever I rebuild the search panes the main table goes to the first page... even with stateSave set to true

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,118Questions: 1Answers: 2,583

    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

  • DreakerDreaker Posts: 13Questions: 6Answers: 0

    @colin Hello Colin, I made a live test case:
    live.datatables.net/nucaqele/1/edit?html,js,output
    In there if you go to any page and then rebuild one pane or any # of them, you'll get back to page 1
    I'm pretty sure that there are workarounds like getting the current page before rebuilding the pane, and then going to that page... but I wonder if that is the intended behavior and if there is an option or something I'm missing to not get back to page 1 after pane/s rebuild

    Thanks Collin

  • sandysandy Posts: 913Questions: 0Answers: 236

    Hi @Dreaker ,

    You can just note the page before you call searchPanes.rebuildPane() and then use page() to set it after. Take a look at this example.

    Thanks,
    Sandy

  • sandysandy Posts: 913Questions: 0Answers: 236
    Answer ✓

    Hi @Dreaker ,

    Colin has just pointed out to me that there is a mistake in the above example. You should also pass false into draw() so that the paging does not reset. See this updated example.

    Thanks,
    Sandy

  • DreakerDreaker Posts: 13Questions: 6Answers: 0

    Thanks to you both!

  • DreakerDreaker Posts: 13Questions: 6Answers: 0

    @sandy I got another question related to this issue, if I'm using scroller how would I go about maintaining current scroll position after pane rebuild? Should I post a different question with a test case? Because in scroller after pane rebuild it always goes to the top of the table

  • colincolin Posts: 15,118Questions: 1Answers: 2,583

    There's not a built in way to make that scroll, so you would need to either use scroller.toPosition() or row().scrollTo() in a similar way that Sandy did with the paging functions in the other example.

    Colin

  • DreakerDreaker Posts: 13Questions: 6Answers: 0
    edited March 2021

    Thanks, I did that, but had to use promises or async in order to make it worth properly because when the dataset is huge, the paneRebuild takes a lot of time and the toPosition() method is executed before the paneRebuild
    But it worked at the end...
    Thanks Colin for the quick reply

This discussion has been closed.