1. #351
    Sencha User
    Join Date
    Jun 2008
    Posts
    69
    Vote Rating
    0
    pouniok is on a distinguished road

      0  

    Default


    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 :

    PHP Code:
    Ext.state.Manager.setProvider(new Ext.ux.state.HttpProvider({
         
    url'/myUrlToSaveState.do'
         
    ,readBaseParams:{action:'readState'}
         ,
    saveBaseParams:{action:'saveState'}
         ,
    autoRead:true
    })); 
    What you have to do :
    • 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 !

  2. #352
    Sencha User
    Join Date
    Oct 2010
    Posts
    18
    Vote Rating
    0
    bullfish is on a distinguished road

      0  

    Default 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:

    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.applyStatethis.state[name] );
            
    grid.view.refresh(true);
        }
    }, 
    this); 
    So what do I have to do to get filters and sorting working?
    I appreciate your help a lot!

    Jens

  3. #353
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,509
    Vote Rating
    374
    jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future

      0  

    Default


    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

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid Search Plugin, ExtJS 5 Complex Data Binding using MVVM


  4. #354
    Sencha User
    Join Date
    Oct 2010
    Posts
    18
    Vote Rating
    0
    bullfish is on a distinguished road

      0  

    Default


    Hi Jozef,

    thanks for your answer. I checked GridFilters.js and I finally solved my problem:

    PHP Code:
    grid.applyStatethis.state[name] );
    grid.fireEvent('beforestaterestore'gridthis.state[name]);  //added
    grid.plugins[0].reload(); //added 
    But I have another problem now. I am dynamically loading the columnModel
    with the following code:

    PHP Code:
    var init_states = {{ states|safe }};

    var 
    projects_grid = new Ext.grid.GridPanel({
    id'projects_grid',
    storeprojects_grid,
    cm: new Ext.grid.ColumnModel({
        
    defaults: {
            
    sortabletrue,
            
    width150
        
    }
    }),
    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);
           }
    },
    // (...) 
    But the column state is not getting restored. Not at page refresh
    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.

  5. #355
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,509
    Vote Rating
    374
    jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future

      0  

    Default


    setConfig doesn't do anything with the state, doesn't apply it. You need to do it yourself.
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid Search Plugin, ExtJS 5 Complex Data Binding using MVVM


  6. #356
    Sencha User
    Join Date
    Oct 2010
    Posts
    18
    Vote Rating
    0
    bullfish is on a distinguished road

      0  

    Default


    And how? What would be the approach to do this?

  7. #357
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,509
    Vote Rating
    374
    jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future

      0  

    Default


    See applyState method of GridPanel, that should give you a good start.
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid Search Plugin, ExtJS 5 Complex Data Binding using MVVM


  8. #358
    Sencha User
    Join Date
    Aug 2007
    Posts
    52
    Vote Rating
    0
    jamie.nicholson is on a distinguished road

      0  

    Default 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

  9. #359
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,509
    Vote Rating
    374
    jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future

      0  

    Default


    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

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid Search Plugin, ExtJS 5 Complex Data Binding using MVVM


  10. #360
    Sencha User
    Join Date
    Aug 2007
    Posts
    60
    Vote Rating
    0
    Rob_mac is on a distinguished road

      0  

    Default 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:

    Code:
    var changed = undefined === lastValue || lastValue !== value;
    This was changed to:

    Code:
    var changed = undefined === lastValue || this.encodeValue(lastValue) !== this.encodeValue(value);
    This fix seems to prevent the dirty flag being incorrectly set to true when there are no changes.