Is there a way for wijmo flexgrid to persist filter/sorting state?

Posted by: victorx on 14 September 2017, 11:26 am EST

  • Posted 14 September 2017, 11:26 am EST

    We have a user case that when user apply any filter/sorting, it can be saved and retrieved, so the next time user open the grid it will show the last grid’s status(assume columns don’t change, but data could change).

    I was wondering whether wijmo provide any static object to do that. I tried to save the object CollectionView.sortDescriptions, but since it is not a static object, it will be killed once grid died. (deep copy is another option but is the worst choice)

    I saw grid has a way to persist on layout, any ideas to persist on sorting/filtering? http://wijmo.com/topic/persist-flexgrid-state/

  • Posted 14 September 2017, 11:26 am EST

    Hello,

    The column layout property of FlexGrid currently saves the column layout of FlexGrid which includes the column properties such as width, index. Hence, it does not saves the sorting and filtering state.

    As mentioned above you would need to save the sorting state in the localStorage or a JSON string using the sortDescriptions property. Further, you may refer to the following demo sample which depicts how you can save the filter state of FlexGrid: http://demos.componentone.com/wijmo/5/Angular/FlexGridFilter/FlexGridFilter/.

    Hope it helps.

    Thanks,

    Manpreet Kaur

  • Posted 14 September 2017, 11:26 am EST

    Thanks for updating, we figured out the way to save sorting, by doing something like this:

    var sortState: any = ;

    for (let description of grid.itemsSource.sortDescriptions) {

    sortState.push({

    property: description.property,

    ascending: description.ascending

    });

    }

    It is inline with what you recommend of saving json string.

    Not scope to filtering at this time, since filter contains all the values in that column

  • Posted 14 September 2017, 11:26 am EST

    Hello,

    It seems that your issue has been resolved. Thank you for sharing your observations with us. Please let us know in case you have any queries further.

    Thanks,

    Manpreet Kaur

  • Posted 2 August 2021, 6:54 am EST

    Hi,

    Can you Please an example/Sample on how to save the sort state and load the last previous sorted data instead of default sort.’

    Thanks

  • Posted 3 August 2021, 3:00 am EST

    Hi,

    You would need to save the sorting state in the localStorage or a JSON string using the sortDescriptions property. Later you can restore that saved state to restore the columns sorting. Further, you may refer to the following demo sample for the same:

    https://www.grapecity.com/wijmo/demos/Grid/PersistingState/angular

    You can also refer to the sample demonstrating the same:

    https://stackblitz.com/edit/angular-uryvkj

    Also, do let us know if this is what you are looking for.

    Regards,

    Ashwin

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels