Hybrid View

  1. #1
    Ext User
    Join Date
    May 2009
    Posts
    11
    Vote Rating
    0
    Lilit is on a distinguished road

      0  

    Question ExtJS grid save cookies for show/hide columns

    ExtJS grid save cookies for show/hide columns


    I have a gridPanel object and I need to save the column configuration in cookies.
    This is my source:

    var cp = new Ext.state.CookieProvider({
    expires: new Date(new Date().getTime()+(1000*60*60*24*30)) //30 days
    });
    Ext.state.Manager.setProvider(cp);

    // create the Grid
    var m_grid = new Ext.grid.GridPanel({
    .............
    stateful: true,
    stateEvents: ['columnresize', 'columnmove', 'show', 'hide']
    });


    Every state event cookie is saved fine except for data about hidden/shown columns. What events should I use? Any help appreciated.
    Lilit

  2. #2
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    94
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    The default stateEvents are ["columnmove", "columnresize", "sortchange"] and initStateEvents also adds a saveState to the colModel 'hiddenchange' event. Also, getState returns hidden state for columns and applyState applies the hidden state correctly.

    So the grid should store the column hidden states!

    ps. Any reason you changed the stateEvents?

  3. #3
    Ext User
    Join Date
    May 2009
    Posts
    11
    Vote Rating
    0
    Lilit is on a distinguished road

      0  

    Default


    Thanks for the quick reply Condor.
    The reason for changing state events was trying to add hidden columns information to the cookies.

    I added this code, which does not produce expected result:

    var m_grid = new Ext.grid.GridPanel({
    ...
    stateful: true,
    stateEvents: ['columnresize', 'columnmove', 'headermousedown', 'show', 'hide'],
    initStateEvents : function(){
    this.colModel.on('hiddenchange', function(){ this.saveState; });
    }
    });

    Could you please add the code for initStateEvents call? I searched ExtJS Api and wasn't able to find the definition for initStateEvents.

    Thanks,
    Lilit

  4. #4
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    94
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    The default stateEvents and initStateEvents are already correct! What happens if you simply remove stateEvents and initStateEvents from your config?

    ps. You did know that you need to specify unique column ids to make state handling work correctly?

  5. #5
    Ext User
    Join Date
    May 2009
    Posts
    11
    Vote Rating
    0
    Lilit is on a distinguished road

      0  

    Default


    Thanks for the tip about id-s.
    Now that I have the unique id-s set up the default stateEvents namely - columnresize, columnmove and sortchange work correctly. However, the hiddenchange state handling - saving information about hidden/showed columns, isn't working.
    Lilit

  6. #6
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    94
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    Your code to register a hiddenchange event is missing a scope. But you should remove it anyway, because the hiddenchange event handler is already registered in initStateEvents (with a delay of 100ms).

  7. #7
    Sencha User
    Join Date
    Jun 2012
    Location
    India
    Posts
    25
    Vote Rating
    2
    _sench_user is on a distinguished road

      0  

    Default


    Quote Originally Posted by Condor View Post
    The default stateEvents are ["columnmove", "columnresize", "sortchange"] and initStateEvents also adds a saveState to the colModel 'hiddenchange' event. Also, getState returns hidden state for columns and applyState applies the hidden state correctly.

    So the grid should store the column hidden states!

    ps. Any reason you changed the stateEvents?
    State is not maintain in case we LOCK any of the column of the GRID. Even it is showing ExtJs internal Error on the console. Please help me to maintain the state of the Grid Columns when we lock the columns.
    Is there any stateEvents for this. Please let me know. Thanks.