Search code examples
sortingfiltergridselectionshieldui

shieldUI grid filter / sort persistence on grid refresh


Is it possible to persist grid sort/filter/selection on grid.refresh() in some smart optimized way? I need to refresh grid on window resize event to adjust to a new window size. I guess refresh internally destroys and recreates grid, not accounting for possible active sort/filter/selection. Because grid can contain a lot of data (virtual scrolling), I would like to a avoid unnecessary db querying, rendering and sorting. I guess I am looking for a refresh which will refresh on existing data.


Solution

  • I found the solution in refresh method it self. It accepts options objects where one can provide current data source options to persist. Example to persist sort and/or filter:

    var options = {
        dataSource: $("#grid").swidget().dataSource
    }
    $("#grid").swidget().refresh(options);
    

    Please stand me correct if I am wrong here. For selections I guess one can retrieve selected indices and reselect after calling refresh.

    EDIT: filter and sort are preserved, but filter row resets (loses all active input values). Could this be a bug? How to keep values in filter row?