stateSave is saving states despite being overridden in stateSaveParams

stateSave is saving states despite being overridden in stateSaveParams

bg7bg7 Posts: 66Questions: 11Answers: 0

In the documentation for stateSaveParams there is an example for overriding the default behavior to only save specific fields.

https://datatables.net/reference/option/stateSaveParams

In this example I'm deleting everything (I think):

https://live.datatables.net/bagodele/1/edit

And yet some of the data is still getting saved to local storage.

I need to make sure the selected row(s) in particular isn't saved. Am I doing something wrong?

Thanks.

Ben

Answers

  • kthorngrenkthorngren Posts: 22,239Questions: 26Answers: 5,116

    I wonder if the select extension is adding the select object after stateSaveParams executes. I updated the test case to include stateLoadParams and you can see it is there. Might be better to use stateLoadParams to remove the objects you don't want restored.

    https://live.datatables.net/bagodele/2/edit

    Kevin

  • bg7bg7 Posts: 66Questions: 11Answers: 0

    Kevin,

    Thanks - that does seem to serve as a workaround. The data is being saved even though it shouldn't be but it's being ignored on the load. Hopefully the save part can be fixed.

    I'm using this with the StateRestore extension. If I'm not mistaken there appears to be an issue with it reloading the state. I created an example here:

    https://live.datatables.net/xavuhute/2/edit

    If you select an item in the searchList and save it, clear out the setting you selected and then restore it, it gets set but not filtered. For example, pick the first user in the name column. Then save that setting. Then clear that user from the searchList dropdown. Then restore the setting you saved. The user gets set in the searchList but the icon doesn't turn dark (indicating an item has been selected) and the table doesn't get filtered appropriately. Any clue why?

    Also, any reason that the removeAllStates button has no confirmation modal by default? The documentation states this explicitly. It seems odd (and potentially dangerous) that deleting an individual item defaults to a confirmation modal but wiping them all out at once doesn't.

    https://datatables.net/reference/button/removeAllStates

    Thanks.

    Ben

  • bg7bg7 Posts: 66Questions: 11Answers: 0

    One other thing. Is there a way to change the button's text either to custom text or an icon? I've been trying to follow the example here:

    https://datatables.net/extensions/buttons/examples/styling/icons.html

    It works for some buttons but I can't seem to get it to work for this one. Hopefully I've just not got the syntax right.

    https://live.datatables.net/situtebu/1/edit

    Thanks.

    Ben

Sign In or Register to comment.