PDA

View Full Version : How to reset the grid state to the state when it got first rendered.



samir_ware
29 Aug 2012, 9:12 PM
Hello all
Is there any way by which I can reset the grid state to the initial state ? i.e. if someone sorts on some column, resize some columns and make some hidden columns visible manually and then with click of one button is it possible to retain the state of the grid to the original state i.e. hide all the hidden column, resize column width to the original width etc. back to the state to which grid was first rendered.
any white paper , link will greatly be appreciated.
Thanks in advance
Samir

sword-it
29 Aug 2012, 10:19 PM
Hi!

you may try following:-



YourGrid.getView().refresh()


or, you may ry to reload your store to make it reset.


yourGrid.getStore().reload();

samir_ware
30 Aug 2012, 1:55 AM
Thanks for the reply sword
Though refreshing the view is not working for me :(

sword-it
30 Aug 2012, 2:07 AM
have you try to reload your store?

yourGrid.getStore().reload();

willigogs
31 Aug 2012, 1:16 AM
Reloading the store shouldn't have any affect on resetting the initial columns shown / column widths of the grid though should it? :-?

To reset the grid to how it first displayed, (and assuming you wouldn't be saving state) the easiest way would probably be to destroy it and then add a new instance?

Or alternatively as SwordIt said - reload the store with the initial load parameters, then use something like the setColumnWidth and setHidden methods to reset all columns manually?
http://docs.sencha.com/ext-js/3-4/#!/api/Ext.grid.ColumnModel-method-setColumnWidth
http://docs.sencha.com/ext-js/3-4/#!/api/Ext.grid.ColumnModel-method-setHidden (http://docs.sencha.com/ext-js/3-4/#!/api/Ext.grid.ColumnModel-method-setColumnWidth)

scottmartin
31 Aug 2012, 8:52 AM
You could always setup a default and use grid.reconfigure(store,columns) to reset?

Scott.