Sep 19, 2014, 2:05 PM
How to set Custom StateProvider?
Hi,
my question is simple: I am using Ext Net 2.5 via Razor syntax (MVC 5.0), where is the right place to set a custom StateProvider?
Now I go in details in order to better explain the problem I a m experiecing. I need to persists the columns preferences per user on server side.
In order to achieve the goal I developed my BF.StateProvider that extends the Ext.state.Provider providing storing/retrieiving GridPanel States from Controller via Direct Methods.
Things don't work: debugging my BF.StateProvider I noticed that during the load, the "get" method is properly called and the configuration is properly retrieved and set it into Privider "state", but after that the "set" method containing the initial configuration is called from StateManager, overriding the previously loaded/stored configuration!
I guessed that my StateProvider implementation was wrong. For checking it I simply replaced the BF.StateProvider code with the standard CookieProvider and I renamed it CUkieProvider. I took the code from here http://docs.sencha.com/extjs/4.1.3/s...CookieProvider. Also using this code the Provider state is properly set but once again after that the StateManager still invokes the "set" overriding the loaded configuration!
In both cases I set the StateProvider into onDocumentReady event in this way:
So my conclusion is that I am setting the StateProvider in a wrong way: where is the right place to set the StateProvider? Maybe that setting it into onDocuemtnReady is too late?
Thanks
my question is simple: I am using Ext Net 2.5 via Razor syntax (MVC 5.0), where is the right place to set a custom StateProvider?
Now I go in details in order to better explain the problem I a m experiecing. I need to persists the columns preferences per user on server side.
In order to achieve the goal I developed my BF.StateProvider that extends the Ext.state.Provider providing storing/retrieiving GridPanel States from Controller via Direct Methods.
Things don't work: debugging my BF.StateProvider I noticed that during the load, the "get" method is properly called and the configuration is properly retrieved and set it into Privider "state", but after that the "set" method containing the initial configuration is called from StateManager, overriding the previously loaded/stored configuration!
I guessed that my StateProvider implementation was wrong. For checking it I simply replaced the BF.StateProvider code with the standard CookieProvider and I renamed it CUkieProvider. I took the code from here http://docs.sencha.com/extjs/4.1.3/s...CookieProvider. Also using this code the Provider state is properly set but once again after that the StateManager still invokes the "set" overriding the loaded configuration!
In both cases I set the StateProvider into onDocumentReady event in this way:
var onDocumentReady = function () {
Ext.state.Manager.setProvider(
Ext.create('Ext.state.CUkieProvider') // where CUkieProvider is CookieProvider code copied and renamed.
//Ext.create('Ext.state.StateProvider') // my custom provider
//Ext.create('Ext.state.CookieProvider') // also using the original one the state does not persists
);
}
@X.ResourceManager().Listeners(ls => { ls.DocumentReady.Handler = "onDocumentReady();"; })
Moreover, setting directly the standard CookieProvider in resource Manager makes persistance working (persistance based on cookie, obiously)@X.ResourceManager().StateProvider(StateProvider.Cookie)
So my conclusion is that I am setting the StateProvider in a wrong way: where is the right place to set the StateProvider? Maybe that setting it into onDocuemtnReady is too late?
Thanks
Last edited by Daniil; Sep 22, 2014 at 1:20 PM.
Reason: Please use [CODE] tags