jQWidgets Forums

jQuery UI Widgets Forums Grid Save/Load State issue with grouped columns

This topic contains 8 replies, has 2 voices, and was last updated by  jlarue 5 years, 12 months ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author

  • jlarue
    Participant

    hello 🙂

    I’m seeing some weird issues when working with autoload/autosave, and trying to reset the state of the grid. I have an example Here

    There are 2 issues I’m seeing:
    1. DataCloneError when restoring initial state
    if you group a column, then click the reset state button in the example, you will see this error in the console.

    2. initial state variable is getting updated inadvertently
    if you group a column, then hit the reset state and groups button in the example, and group a column a second time, you can see in the console that the initial state variable I have now includes groups. I’m not sure if this is a reference/value issue specific to JavaScript or not.

    Basically, in order to account for the first issue, I figured clearing the groups first before I reset the grid state might help. Because my initial state is being updated though, I’m still unable to reset the grid to tis original state.

    What do you guys think? Am I doing something wrong here?

    thanks for your help! 🙂


    Todor
    Participant

    Hello jlarue,

    The proper way of state reset is to use the methods for clearing grouping/filtering/sorting etc. – cleargroups/clearfilters etc.

    Let us know if you need further assistance.

    Best Regards,
    Todor

    jQWidgets Team
    https://www.jqwidgets.com


    jlarue
    Participant

    Thanks Todor. Is there an easy way reset the order/visibility of columns ?

    Generally, the response from the team about resetting the state is to capture the it in the Ready function and restore it later. Have there been changes to the framework that make that a non-viable solution going forward?


    Todor
    Participant

    Hello jlarue,

    You could use setcolumnindex method like in this example.

    Also for your second question – you could save the state in the ready function and use it later. This is still working. The problem is in the way of using loadstate method. You are saving the state at very beginning with empty data for grouping/sorting etc. and expecting to refresh the grid with loadstate and initial saved state. But the method do not reset the groups in grouping if there is no groups selected in the state, as you expect, instead it do nothing. I hope this makes sense to you.

    Best Regards,
    Todor

    jQWidgets Team
    https://www.jqwidgets.com


    jlarue
    Participant

    If the loadstate function doesn’t restore groups and sorting that is no big deal – I could just call resetgroups and manually resort before or after loadstate.

    The problem is – that’s not working for me. When there are groups applied, loadstate is throwing errors instead of just ignoring the groups. Also, my initial state is being changed as I work with the grid, so I can’t reliably restore to that. It seems like these are bugs – can you confirm the intended behavior here?

    I’d really like to avoid manually setting the index and visibility on every column in my grid (on every grid in my application). That is going to be a big maintenance problem as columns are added/removed/renamed.


    Todor
    Participant

    Hello jlarue,

    I updated your example and now it resets groups/sorting/column position on button click. Please review it whether it fits your needs.

    Best Regards,
    Todor

    jQWidgets Team
    https://www.jqwidgets.com


    jlarue
    Participant

    Todor,

    Looking at your fiddle there, I can see that you turn autosavestate and autoloadstate off. While that does make the reset state work properly, it doesn’t fit my use case because I need to have autoloadstate and autosavestate enabled. With those enabled, the problem still remains.

    ultimately, my users want to make changes to the grid, browse away from the page, and have the grid be the same when they come back. They also need a way to reset the state of the grid, removing the customizations they have made.


    Todor
    Participant

    Hello jlarue,

    Please check this workaround.

    Best Regards,
    Todor

    jQWidgets Team
    https://www.jqwidgets.com


    jlarue
    Participant

    Thanks Todor – it’s a simple solution, and it works! I appreciate the help! 🙂

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.