How can I exclude the # rows displayed from State Restore? - Page 2

How can I exclude the # rows displayed from State Restore?

2»

Answers

  • desperadodesperado Posts: 159Questions: 33Answers: 4
    edited March 2022

    @colin stateRestore.saveState.length = false is working however paging is still not working.

    I have the following configuration and the saved state includes the page I am on which we really don't want. In fact I don't know how this will work if the number of pages changes. If I save a state on page 5 and then the data becomes a smaller set with only 3 pages how can state restore return to page 5 which no longer exists.

    I think the paging=false is only broken for ajax. I don't understand why so many of these features depend on if you are getting your state data from ajax or memory. That shouldn't affect the logic but for some reason it does.

    Anyway should I start a new thread on the paging issue? It is mentioned in this thread but I don't think it was addressed. You opened this ticket in regard to paging DD-2493 based on your comment above.

    This is my configuration.

                    buttons: [
                        {
                            extend: 'savedStatesCreate',
                            collectionLayout: 'rcoi-dt-state-restore-button-group-hack',
                            config: {
                                creationModal: true,
                                saveState: {
                                    paging: false,
                                    length: false
                                },
                                ajax: stateRestoreAjax,
                                splitSecondaries: [
                                    { extend: 'updateState',
                                      init: savedStateActionInit
                                    },
                                    { extend: 'removeState',
                                        init: savedStateActionInit
                                    },
                                    { extend: 'renameState',
                                        init: savedStateActionInit
                                    },
                                    /*  Add Make Public Button */
                                    {   init: getMakePublicButtonLabel,
                                        action: togglePublicState
                                    }
                                ]
                            }
                        },
    
  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    Thanks. Sandy is back in again tomorrow, he'll be better placed to diagnose then,

    Colin

  • desperadodesperado Posts: 159Questions: 33Answers: 4

    @colin Thanks for the update.

  • sandysandy Posts: 913Questions: 0Answers: 236

    Hi @desperado ,

    I've updated a previous version of your test case and it seems to be working fine for me. Could you please let me know how you can reproduce any errors that you are seeing there?

    Thanks,
    Sandy

  • desperadodesperado Posts: 159Questions: 33Answers: 4

    @sandy when I run your test case in chrome (Version 99.0.4844.84 (Official Build) (x86_64)) it fails to start with the following error.

    Uncaught Error: The version number provided is lower than the existing one.
    at q.<anonymous> (idbstore.min.js:12:158)

    In mozilla it is working.

    When I use nightly for Datatables and StateRestore in my application I am still seeing it fail. I don't understand why yet.

    I can see that I am using nightly.

    Paging is clearly set to false.

    But when I save state while on page 4. If I switch to page 1 the state becomes inactive. If I activate the state it switches to page 4.

    Do you have any suggestions on how I can debug this?
    The saved state looks like this stored in my DB

    {
    "c": {
        "_createInSaved": true,
        "create": true,
        "creationModal": true,
        "i18n": {
            "creationModal": {
                "button": "Create",
                "colReorder": "Column Order",
                "columns": {
                    "search": "Column Search",
                    "visible": "Column Visibility"
                },
                "length": "Page Length",
                "name": "Name:",
                "order": "Sorting",
                "paging": "Paging",
                "scroller": "Scroll Position",
                "search": "Search",
                "searchBuilder": "SearchBuilder",
                "searchPanes": "SearchPanes",
                "select": "Select",
                "title": "Create New State",
                "toggleLabel": "Includes:"
            },
            "duplicateError": "A state with this name already exists.",
            "emptyError": "Name cannot be empty.",
            "emptyStates": "No saved states",
            "removeConfirm": "Are you sure you want to remove %s?",
            "removeError": "Failed to remove state.",
            "removeJoiner": " and ",
            "removeSubmit": "Remove",
            "removeTitle": "Remove State",
            "renameButton": "Rename",
            "renameLabel": "New Name for %s:",
            "renameTitle": "Rename State"
        },
        "modalCloseButton": true,
        "preDefined": {
        },
        "remove": true,
        "rename": true,
        "save": true,
        "saveState": {
            "colReorder": true,
            "columns": {
                "search": true,
                "visible": true
            },
            "length": false,
            "order": true,
            "paging": false,
            "scroller": true,
            "search": true,
            "searchBuilder": true,
            "searchPanes": true,
            "select": true
        },
        "splitSecondaries": [
            {
                "extend": "updateState"
            },
            {
                "extend": "removeState"
            },
            {
                "extend": "renameState"
            },
            {
            }
        ],
        "toggle": {
            "colReorder": false,
            "columns": {
                "search": false,
                "visible": false
            },
            "length": false,
            "order": false,
            "paging": false,
            "scroller": false,
            "search": false,
            "searchBuilder": false,
            "searchPanes": false,
            "select": false
        }
    },
    "childRows": [
    ],
    "ColReorder": [
        0,
        1,
        2,
        3,
        4,
        5,
        6,
        7,
        8,
        9,
        10,
        11
    ],
    "columns": [
        {
            "search": {
                "caseInsensitive": true,
                "regex": false,
                "search": "",
                "smart": true
            },
            "visible": false
        },
        {
            "search": {
                "caseInsensitive": true,
                "regex": false,
                "search": "",
                "smart": true
            },
            "visible": true
        },
        {
            "search": {
                "caseInsensitive": true,
                "regex": false,
                "search": "",
                "smart": true
            },
            "visible": true
        },
        {
            "search": {
                "caseInsensitive": true,
                "regex": false,
                "search": "",
                "smart": true
            },
            "visible": true
        },
        {
            "search": {
                "caseInsensitive": true,
                "regex": false,
                "search": "",
                "smart": true
            },
            "visible": true
        },
        {
            "search": {
                "caseInsensitive": true,
                "regex": false,
                "search": "",
                "smart": true
            },
            "visible": true
        },
        {
            "search": {
                "caseInsensitive": true,
                "regex": false,
                "search": "",
                "smart": true
            },
            "visible": true
        },
        {
            "search": {
                "caseInsensitive": true,
                "regex": false,
                "search": "",
                "smart": true
            },
            "visible": true
        },
        {
            "search": {
                "caseInsensitive": true,
                "regex": false,
                "search": "",
                "smart": true
            },
            "visible": true
        },
        {
            "search": {
                "caseInsensitive": true,
                "regex": false,
                "search": "",
                "smart": true
            },
            "visible": true
        },
        {
            "search": {
                "caseInsensitive": true,
                "regex": false,
                "search": "",
                "smart": true
            },
            "visible": true
        },
        {
            "search": {
                "caseInsensitive": true,
                "regex": false,
                "search": "",
                "smart": true
            },
            "visible": true
        }
    ],
    "order": [
        [
            3,
            "asc"
        ]
    ],
    "page": 3,
    "search": {
        "caseInsensitive": true,
        "regex": false,
        "search": "",
        "smart": true
    },
    "searchBuilder": {
        "criteria": [
            {
                "condition": "!=",
                "data": "Pending Children",
                "origData": "pendingChildren",
                "type": "string",
                "value": [
                    " "
                ]
            },
            {
                "condition": "!=",
                "data": "Award Status",
                "origData": "awardStatus",
                "type": "string",
                "value": [
                    "OK"
                ]
            }
        ],
        "logic": "AND"
    },
    "start": 0,
    "stateRestore": {
        "isPredefined": false,
        "isPreDefined": false,
        "state": "Page 4 test",
        "tableId": "award-person-table"
    },
    "time": 1648749278318}
    
  • desperadodesperado Posts: 159Questions: 33Answers: 4
    edited March 2022

    @sandy I just noticed that even in your example the State becomes inactive when you change pages. So that is one symptom perhaps you can chase down.

    To recreate in your example http://live.datatables.net/rivurece/1/edit
    1) Switch to page 4
    2) Create view named "Page 4 Test"
    3) Notice that the "Page 4 Test" is active in the menu (green)
    4) switch to page 1
    5) Notice that "Page 4 Test" is no longer active in the menu (not green)
    This part is different for my code vs the test code
    6) select "Page 4 Test" to activate it.
    7) Notice the view switches to Page 1 (in my code it switches to page 4)
    8) Notice the view is NOT active even though you just selected it (In my code it is active since we are on page 4)
    9) Switch manually to page 4
    10) Notice the View is now active (green) again in the menu.

    PS: I got your example working in Chrome by deleting my IDBStore database. I didn't know exactly how that worked so had to chase it down a bit.

  • desperadodesperado Posts: 159Questions: 33Answers: 4

    @sandy Update, I found my issue causing the page to be restored. I had some remnants of stateSaveCallback and stateLoadCallback which should have been removed. Sorry about that, but there is still the bug I mention in my last post.

    My local code tests now match my last post in steps 6-10. So it appears the page is NOT being restored however the page is preventing "Active State" from working correctly.

    Another test I did to prove this is as follows.

    1) Go to page 1 and save state as "Page 1"
    2) Go to page 4 and save state as "Page 4"
    3) Select "Page 4" saved state
    4) Note that "Page 1" is active
    5) Select Page 4, NOTE "Now Page 4 is active"

    So the remaining bug is when "paging" is set to false, paging is still be used to determine if a state is active or not.

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    I'll add this to Sandy's list for when he's back in, but it won't be until next week I'm afraid,

    Colin

  • desperadodesperado Posts: 159Questions: 33Answers: 4

    @colin thanks for letting me know.

    Any idea when the current fixes will be released? I have a pending release of my system and trying to decide if I need to pull from nightly or not.

    The length and paging fixes are important since states saved without them will remain broken even after the fix unless deleted and recreated. This last issue is less critical since it is just misinformation to the user and when fixes shouldn’t require replacing the saves states hopefully.

  • sandysandy Posts: 913Questions: 0Answers: 236

    Hi @desperado ,

    I've made a simple test case that doesn't use IDB store and it works fine there.

    I'm not an expert on IDBStore, but when I update the dbVersion and follow the steps you list above I also do not see an issue - see here. I'm unable to delete certain states when I do this, but I think this is down to the IDBStore configuration. This suggests to me that the problems that you are seeing have been resolved and are now down to something that IDBStore is doing?

    Can you try stripping IDBStore completely so it is fresh and make a brand new one? Does it work for you then?

    Thanks,
    Sandy

  • desperadodesperado Posts: 159Questions: 33Answers: 4
    edited April 2022

    @sandy

    This test case fails without ajax or IDB.
    http://live.datatables.net/lutozipi/1/edit?js,output

    Same test steps
    1) Go to page 1 and save state as "Page 1"
    2) Go to page 4 and save state as "Page 4"
    3) Select "Page 4" saved state
    4) Note that "Page 1" is active
    5) Select Page 4, NOTE "Now Page 4 is active"

    More steps to prove the point :smile:
    6) Select Page 3, No States are active
    7) Select Page 1, Now "Page 1" state is active and "Page 4" state is inactive
    8) Select Page 4, Now "Page 4" state is active and "Page 1" state is inactive.

  • desperadodesperado Posts: 159Questions: 33Answers: 4
    edited April 2022

    @sandy Sorry my last example still had some IDB code, it wasn't in use but it was there so might confuse the case.

    Here is an example without any IDB reference and not using Ajax. This too has the issue.
    http://live.datatables.net/zadagasu/1/

    I am trying now to test why your test case doesn't fail and will report back if I can figure it out.

  • desperadodesperado Posts: 159Questions: 33Answers: 4
    edited April 2022

    Now I am getting message that the link I provided was created anonymously so just in case here is another copy from my account.

    http://live.datatables.net/loluseri/1/edit

  • desperadodesperado Posts: 159Questions: 33Answers: 4
    edited April 2022

    @sandy I think I found the reason yours worked. You need to include search builder for the issue to happen. This is basically your test case with search builder added and not it has same problem as my test case.

    http://live.datatables.net/jizatane/1/edit

    Test
    1) Create State "State 1" (initial load so page 1)
    2) Switch to Page 4 (State becomes inactive), Create State "State 2"
    3) Switch to page 1 ("State 1" becomes active, "State 2" becomes inactive)
    ...

    Delete states
    Comment out SearchBuilder
    Repeat test and things work now.

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    That's good info, thanks for delving into it. We'll take a nose and report back,

    Colin

  • sandysandy Posts: 913Questions: 0Answers: 236

    Hi @desperado ,

    Thanks for doing the work to track down the issue further, something definitely isn't right there. I've raised an issue internally (DD-2531 for my reference) and will report back here when there is an update.

    Thanks,
    Sandy

  • desperadodesperado Posts: 159Questions: 33Answers: 4

    @sandy no problem sorry I had so much trouble tracking this one down I appreciate your effort!

    FYI stateRestore and searchBuilder are in my production system now so I am all in LOL

    Cheers

  • sandysandy Posts: 913Questions: 0Answers: 236

    Hi @desperado ,

    That should hopefully be the issue fixed now. I've added the latest nightly to the above simplified example. I've also updated the IDB store example and it seems to be working there - not sure how to get rid of the old states though once I update the version number!

    This will be available in the next StateRestore release which we hope will be in the next few weeks. Until then you can access the fix from the nightly builds.

    Thanks,
    Sandy

  • desperadodesperado Posts: 159Questions: 33Answers: 4

    @sandy Thanks! I will test it out and let you know.

    To clear IDB store in chrome click on storage, clear site data (while on the live.datatables.net page). I assume other browsers are similar.

Sign In or Register to comment.