Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
175
Export Current Grid State
posted

So, I'm trying to figure out a way to persist grid customization across user sessions for our application.  So I don't need to persist the data being displayed, however, I do need to be able to persist what order the columns are currently in for our table, as the user needs to be able to drag and order the columns around and will want that to persist across sessions.  We also need to be able to know which Columns are being shown and hidden such that I would be able show/hide those upon the next time a user logs in.

Any insight would be greatly appreciated.

Thanks,

-Randall Blevins

Parents Reply
  • 175
    Offline posted in reply to Hristo Anastasov

    Hristo - Here is a very rough version: https://stackblitz.com/edit/angular-wcburc

    For this version I stripped out the dynamic columns service call I was doing to provide the columns to the grid and the service call to get the data. I am seeing similar behavior with the Hidden assignment not applying appropriately.

    To reproduce:

    1) Hide a column

    2) Save the grid state using the button under the apps menu button

    3) Unhide the Hidden column

    4) Load the Grid from the apps menu button

    The column that was hidden should still be visible.

    When I was looking into this, it appears when I look at the main grid object that is getting the grid data through the @ViewChild (in the stackblitz it is the productResults variable), if I look at the this.productResults.columns[0].hidden field, it appears to not be picking up the change from the main columns variable that is feeding the grid in the html.

    I did find a work around by doing a comparison between the two columns and then doing an assignment for the hidden attribute, however, I had to set this on a timeout as for some reason if you don't it was getting overwritten by something (my thought was maybe the original columns assignment from the load was triggering some kind of update and rolling it back). Setting something to timeout is not really ideal of course.

    The work around code is currently commented out in the stackblitz.  It's in the loadSavedGrid method which calls the applyHidden method in the product-grid.component.ts.

    -Randall

Children