PDA

View Full Version : Grid question


RPG-Animal
06-01-2009, 03:47 PM
Hello,

I've been playing around with the grid functionality for the last week and can't believe I ever thought subfiles were cool. Hopefully I'm not getting overly ambitious with this question...

Say a user resizes a grid column, or moves a column from one position to another. Is there an easy way I can have the program "remember" the size or location change, so that the next time the user calls up the same grid it looks the same as before? I presume I would need to store something on the back end?

Thanks!

sean.lanktree
06-01-2009, 06:11 PM
No backend logic is required to handle this. It will all be handled by your front end code. If you already have the "id" config option specified for your grid, only 2 additional lines are needed. Otherwise, 3 additional lines of code are needed.

The first line of code can be placed immediately after your standard "onReady"....

Ext.onReady(function(){

Ext.state.Manager.setProvider(new Ext.state.CookieProvider());



The second (and possibly third) line(s) of code will fall under your grid definition...

var myGrid = new Ext.grid.GridPanel({
title:'My grid',
id:'myGrid',
stateful:true,



This will now automatically remember any column resizes, column moves, and column sorts.

If you need any additional functionality, you would have to add the "stateEvents" config option to your grid. You can find more information on this under the ExtJS documentation under GridPanel.

RPG-Animal
06-02-2009, 11:45 AM
Wow, you get all that functionality in just two lines of code?! That is too cool, thanks! Can't wait to show this to my users...