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
    86
    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
    86
    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
    86
    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
    Ext User
    Join Date
    May 2009
    Posts
    11
    Vote Rating
    0
    Lilit is on a distinguished road

      0  

    Default


    Sorry, I didn't put it clearly in my previous post. I am getting the result of hide/show information not being saved with stateEvents and initStateEvents declaration removed.
    Lilit

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

      0  

    Smile SOLVED

    SOLVED


    Hi Condor,
    I fingered what my mistake was.
    The application I am developing has several grid objects, and one function for creating a grid. For every grid I was passing the distinct GridPanel parameters, such as columns, store, etc.. but initializing with same stateId. So the cookies were being saved not for each grid but for the mixed up structure. I kept wandering why my changes in one of the grid would propogate to all others.

    Setting the stateId property unique for each grid solved my problem - hidden columns information is being saved in cookies for each grid.
    Thank you very much for your help.
    Lilit

  9. #9
    Ext User
    Join Date
    Jul 2009
    Posts
    3
    Vote Rating
    0
    Slb is on a distinguished road

      0  

    Default Restore stateful Grid Columns on click of a button

    Restore stateful Grid Columns on click of a button


    Hi,
    In a grid Panel, i would like to have a button "Restore Default" clicking on which it should remove columns which are hided and saved in the cookies and refresh the Grid back to the original state. Can anyone tell me how can i do this?

  10. #10
    Sencha User dotnetwise's Avatar
    Join Date
    Mar 2010
    Location
    Iasi, Romania
    Posts
    31
    Vote Rating
    1
    dotnetwise is on a distinguished road

      0  

    Default Reset Default

    Reset Default


    I would like this button as well. How can I insert it on the dropdown menu of every column?
    Quote Originally Posted by Slb View Post
    Hi,
    In a grid Panel, i would like to have a button "Restore Default" clicking on which it should remove columns which are hided and saved in the cookies and refresh the Grid back to the original state. Can anyone tell me how can i do this?

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi