-
5 Jan 2011 2:09 AM #351
It's working now !
So if someone, like me, calls its grids without any request but by instantiating new objects, you can handle state with only that code in your main page header :
What you have to do :PHP Code:Ext.state.Manager.setProvider(new Ext.ux.state.HttpProvider({
url: '/myUrlToSaveState.do'
,readBaseParams:{action:'readState'}
,saveBaseParams:{action:'saveState'}
,autoRead:true
}));
- Make your saveState action return a json like : {success: true}
- Make your readState action return a json like : {success: true, data:[{name: 'list1', value: 'encodedState1'},{name: 'list2', value: 'encodedState2'}, ...]}
Then, when your grid saves its state, the HttpProvider automaticaly replace the old one with the new one in the state manager if your json returned success: true.
Hope it could help someone !
-
17 Jan 2011 7:21 AM #352
Applying state to GridFilter
Applying state to GridFilter
Hello,
first of all thank you very much for this great piece of code and
all the examples on your webpage.
I am using your script to save the column data for different views.
I have a button, where people change the view and all the grid meta
data is getting loaded manual. Everything is working fine besides the
fact, that the filters of the GridFilter plugin and the sorting information
is not getting used and I don´t know how to do this.
If people change the view and they refresh the page, the filters and
sorting is just loaded without problem. I guess, thats because the
state information is there before the component renders?
This is my onReadSuccess-function. I made some changes to
apply the sent state data to the grids:
So what do I have to do to get filters and sorting working?PHP Code:Ext.each(data, function(item) {
var name = item[this.paramNames.name]
this.state[name] = this.decodeValue(item[this.paramNames.value]);
var grid = Ext.getCmp(name);
if(grid && grid.view) {
tocon('applyState for ' + grid + ":" + this.state[name]);
grid.applyState( this.state[name] );
grid.view.refresh(true);
}
}, this);
I appreciate your help a lot!
Jens
-
17 Jan 2011 11:43 AM #353
Sorting should work out of the box, at least it works at http://cellactions.extjs.eu/. Unfortunately, I know nothing about filters, if they have state keeping routines (getState, applyState, stateEvents) implemented.
Jozef Sakalos, aka Saki
A lot of valuable info at:
Saki's Extensions and Plugins
Saki's Extensions and Plugins Docs
Saki's Examples, Latest: Grid in Card Layout
Saki's Blog, Featured: Writing a Big Application in Ext, Latest: Grid MultiSearch Plugin Video
-
19 Jan 2011 6:11 AM #354
Hi Jozef,
thanks for your answer. I checked GridFilters.js and I finally solved my problem:
But I have another problem now. I am dynamically loading the columnModelPHP Code:grid.applyState( this.state[name] );
grid.fireEvent('beforestaterestore', grid, this.state[name]); //added
grid.plugins[0].reload(); //added
with the following code:
But the column state is not getting restored. Not at page refreshPHP Code:var init_states = {{ states|safe }};
var projects_grid = new Ext.grid.GridPanel({
id: 'projects_grid',
store: projects_grid,
cm: new Ext.grid.ColumnModel({
defaults: {
sortable: true,
width: 150
}
}),
viewConfig: {
onDataChange: function(){
this.cm.setConfig(this.ds.reader.jsonData.columns);
// I put the initState() here because I thought, the cm is set then..
Ext.state.Manager.getProvider().initState(init_states);
this.syncFocusEl(0);
}
},
// (...)
and not when I press my change-view-and-load-a-new-state button. Everything
worked fine, when the column model was static. I guess, the HttpProvider
does not find the columns or they are not loaded yet when the
pages is loaded.
What can I do about this? Any ideas?
Thanks for your help.
-
19 Jan 2011 12:39 PM #355
setConfig doesn't do anything with the state, doesn't apply it. You need to do it yourself.
Jozef Sakalos, aka Saki
A lot of valuable info at:
Saki's Extensions and Plugins
Saki's Extensions and Plugins Docs
Saki's Examples, Latest: Grid in Card Layout
Saki's Blog, Featured: Writing a Big Application in Ext, Latest: Grid MultiSearch Plugin Video
-
19 Jan 2011 12:44 PM #356
And how? What would be the approach to do this?
-
19 Jan 2011 12:55 PM #357
See applyState method of GridPanel, that should give you a good start.
Jozef Sakalos, aka Saki
A lot of valuable info at:
Saki's Extensions and Plugins
Saki's Extensions and Plugins Docs
Saki's Examples, Latest: Grid in Card Layout
Saki's Blog, Featured: Writing a Big Application in Ext, Latest: Grid MultiSearch Plugin Video
-
20 Feb 2011 8:30 AM #358
SmartCheckBoxSelctionModel reverts State Provider to cookies
SmartCheckBoxSelctionModel reverts State Provider to cookies
Thanks Saki for a great extension. Found a problem with SmartCheckBoxSelectionModel v1.17.
It stomps the State provider, which means all future state changes are saved to the cookies event when you configure your app to use your extension.
It should at least check if there is a provider defined before stomping it.
I'll drop a note on the other thread.
Offending Code in SmartCheckBoxSelectionModel
Code:onHdMouseDown : function(e, t){ //............ // Load the state manager Ext.state.Manager.setProvider(new Ext.state.CookieProvider()); Ext.state.Manager.loaded = true; }, onMouseDown : function(e, t){ //............ // Load the state manager Ext.state.Manager.setProvider(new Ext.state.CookieProvider()); Ext.state.Manager.loaded = true; },Last edited by jamie.nicholson; 20 Feb 2011 at 9:22 AM. Reason: Clarity
-
20 Feb 2011 11:39 AM #359
Thanks for the info. Yes, the extension should check the provider and throw an exception if it doesn't find one forcing the developer to setup one to his liking.
Jozef Sakalos, aka Saki
A lot of valuable info at:
Saki's Extensions and Plugins
Saki's Extensions and Plugins Docs
Saki's Examples, Latest: Grid in Card Layout
Saki's Blog, Featured: Writing a Big Application in Ext, Latest: Grid MultiSearch Plugin Video
-
16 Mar 2011 4:01 AM #360
queueChange - lastValue/value comparison
queueChange - lastValue/value comparison
Apologies if this is a known issue - I searched the thread but couldn't find it mentioned anywhere.
I'm using HttpProvider for saving a grid's state, and all is working great (thanks!) except that I noticed that an empty queue was getting saved to the database every once in a while. Further investigation led to a change to the following line of code within the queueChange function:
This was changed to:Code:var changed = undefined === lastValue || lastValue !== value;
This fix seems to prevent the dirty flag being incorrectly set to true when there are no changes.Code:var changed = undefined === lastValue || this.encodeValue(lastValue) !== this.encodeValue(value);


Reply With Quote