1. #1
    Ext JS Premium Member
    Join Date
    Oct 2007
    Location
    Herndon, VA
    Posts
    265
    Vote Rating
    3
    durlabh is on a distinguished road

      0  

    Default [2.x][CLOSED] GridPanel applyState: Hidden doesn't hide column header

    [2.x][CLOSED] GridPanel applyState: Hidden doesn't hide column header


    I'm not sure whether others have noticed this as well or not. In couple of my cases, I noticed that when a column is hidden in the stored state and state is restored on a rendered grid, grid headers remain visible while content is hidden. I propose the following fix:

    Code:
    Ext.grid.GridPanel.override({
        applyState : function(state){
            var cm = this.colModel;
            var cs = state.columns;
            if(cs){
                for(var i = 0, len = cs.length; i < len; i++){
                    var s = cs[i];
                    var c = cm.getColumnById(s.id);
                    if(c){
                        c.width = s.width;
                        var oldIndex = cm.getIndexById(s.id);
                        cm.setHidden(oldIndex, s.hidden);
                        if(oldIndex != i){
                            cm.moveColumn(oldIndex, i);
                        }
                    }
                }
            }
            if(state.sort){
                this.store[this.store.remoteSort ? 'setDefaultSort' : 'sort'](state.sort.field, state.sort.direction);
            }
        }
    });

  2. #2
    Sencha User
    Join Date
    Apr 2012
    Location
    Austin, Texas
    Posts
    2
    Vote Rating
    0
    brian.moeskau is an unknown quantity at this point

      0  

    Default


    I'm assuming you are on an older version. That code has had this since at least 2.1 and seems to work fine:
    Code:
                    if(c){
                        c.hidden = s.hidden;
                        c.width = s.width;

  3. #3
    Ext JS Premium Member
    Join Date
    Oct 2007
    Location
    Herndon, VA
    Posts
    265
    Vote Rating
    3
    durlabh is on a distinguished road

      0  

    Default


    Brian, column model does change but there are no updates on the screen in this case. So, is it by design that we must call grid.getView().refresh(true)?

  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


    @brian:

    You assume that applyState is only called with the state from the state manager when the component is created.

    However, several people use getState and applyState to save and restore column layout (e.g. a "Restore columns" button).

    This means that applyState can also be called when the grid is already rendered.

  5. #5
    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


    i have given Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
    and " stateful: true," to save the columns of grid in cookies and get those. I would like to have a button for the grid which will restore all the columns. Can you pls guide me how can i use the applyState in the restore buttton?

  6. #6
    Sencha User
    Join Date
    May 2011
    Posts
    9
    Vote Rating
    0
    sven_s is on a distinguished road

      0  

    Default this still occurs in 4.0.7

    this still occurs in 4.0.7


    Quote Originally Posted by Condor View Post
    @brian:You assume that applyState is only called with the state from the state manager when the component is created.However, several people use getState and applyState to save and restore column layout (e.g. a "Restore columns" button).This means that applyState can also be called when the grid is already rendered.
    To me it seems this still doesn't work. In 4.0.7 I also use getState and applyState in a grid panel. applyState hides some columns (content) but the header still remain...