PDA

View Full Version : How to use getState in a grid?



darkhorni
18 Jun 2012, 5:00 AM
Here (http://docs.sencha.com/ext-js/4-1/#%21/api/Ext.grid.Panel-method-getState) it says that I can get width (of columns I guess) but only thing I can get is the columns IDs.
My code:

grid.getState()

sword-it
18 Jun 2012, 5:45 AM
Hi darkhorni,

getState() method return gridPanel width, height. you can check this on grid "resize" event.



listeners:{
resize : function(){
var properties =this.getState();
return properties;
}
}

darkhorni
18 Jun 2012, 6:30 AM
I was doing it with a button so I have realized that "
If your original column width is not changed getState does not return width info for this column."

Lyynx
18 Jun 2013, 8:19 PM
This is a problem for me. I persist the Grid state in a database and then reload the state. If the overall width of the Grid has not changed then the width is not saved. Reloading that data then resets the width of the Grid back to the default (because what else can it be loaded as?)
So state is not really state, its changed state. if you persist changed state only then you can't reload it if the width didn't just change.
It's only really a problem if a column is changed (state changes). So the state saved has to become a additive process of the state, (ie add to the state, not overwrite the state saved).

That may well be my work around. This adds a level of complexity as I will need to pull apart the state and examine it, rather than just save it and load it.