Paging issue using SearchPanes with cascadePanes set to true

Paging issue using SearchPanes with cascadePanes set to true

casscass Posts: 6Questions: 3Answers: 0
edited October 2022 in Free community support

Test case: https://jsfiddle.net/aghf9xvb/4/

I am aware that there is a compatibility issue between SearchPanes and StateRestore - this might be linked to that issue.

Steps to reproduce in the test case:
1. Select any page of the DataTable other than 1, e.g.page 5
2. Refresh the frame containing the DataTable
3. Page 1 is displayed, despite stateSave being set to true in the table spec

This occurs with cascadePanes set to true. If it is changed to false and the test re-run, the user-selected page is preserved on refresh.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 57,703Questions: 1Answers: 9,195 Site admin
    Answer ✓

    Thanks for flagging this up. It looks like SearchPanes is resetting the paging on its own initialisation. I don't have an immediate fix for this I'm afraid, but I have logged it so I can look into it. Hopefully for the next SearchPanes release, but I can't guarantee that.

    Allan

  • casscass Posts: 6Questions: 3Answers: 0

    I've worked around this issue by saving the current page in sessionStorage when the user leaves the screen.

    I then placed this code after the table definition:

    table.on("init.dt", function (e: any) {
        if (sessionStorage.DTCurrentPage !== undefined) {
            let pageNum: number = parseInt(
                sessionStorage.DTCurrentPage
            );
            if (!isNaN(pageNum)) {
                table.page(pageNum).draw(false);
            }
    
            // Remove saved data from sessionStorage
            sessionStorage.removeItem("DTCurrentPage");
        }
    });
    

    Seems to be working well so far. Also, it has the benefit of returning to the selected page even when a filter has been applied, which does not normally happen with SearchPanes even when cascadePanes is set to false.

Sign In or Register to comment.