View Full Version : Grid ApplyState column hidden then unhidden - data shows, but no header

30 Oct 2013, 11:36 AM
4.2.1 and 4.2.2 nightly 9/24

If your grid defaults a column to be hidden. Then later you change state to unhide it and save that state. On later usage of that saved state via applyState the unhidden column doesn't appear right. The data is there but the header is missing.

Test case:

30 Oct 2013, 11:45 AM
Additional info:

If you applyState before the grid component is fully initialized, the unhidden column will appear fine.

The bug only happens after the grid is visible and you applyState to unhide a column. Seems like something on headerCt is missing during applyState after render.

30 Oct 2013, 12:28 PM
Are you saying that you're calling applyState yourself? If so, it's not really intended to be used that way. It's called as a template method during the component lifecycle, so certain "timings" are expected of it.

31 Oct 2013, 4:27 AM
Yes, just like this recent related thread:

What else must happen to update the grid's header? The next action I plan to try is Reconfigure. I just can't find any additional usage of applyState within Ext to learn more about where applyState fits into the lifecycle.

I suppose my last resort will be to completely re-create the grid when the user chooses to change to a different saved "View" of the grid (View being a saved collection of grid/column attributes).

31 Oct 2013, 4:46 AM
In that case I don't think that your test case (or the one in the other thread) is a valid bug. The intent of applyState is that it be called during initialization of the component.

The grid header is made up of various column objects, you can just call show/hide on them.

31 Oct 2013, 11:46 AM

And for those keeping track, reconfigure didn't get me very far. I'm now going down the path of a full grid destroy then add with a tweaked config. This will ensure the grid starts up with the right 'state' applied and everything will happen in the usual lifecycle.

14 Mar 2014, 10:26 AM
Any luck resolving this? I'm having the same problem in a scenario that I don't feel is unreasonable at all. I have a reusable grid subclass that retrieves a column configuration from the server based on which data it's being used to display and then uses reconfigure to set the columns. I haven't had any issues until I tried to restore state. This obviously has to happen after the reconfigure, because the grid doesn't have columns to which to restore the state until after the reconfigure occurs. It mostly works, except that hidden columns aren't accounted for in the view when calculating data column widths and the headers don't line up with the data below.

The grid won't restore state at all if stateId is set in the constructor -- only works if set after reconfigure and before calling initState. I believe this is because otherwise the state gets overwritten when the grid panel starts in it's default, no-column state before it knows which columns will be shown.

I've also found that if I don't use suspendLayout then the view renders data for hidden columns (and the header renders text for hidden columns over the top of other columns -- very bad).

this.suspendLayout = true;
this.reconfigure(this.getStore(), columns);
this.stateId = 'record-grid-' + this.entity;
this.suspendLayout = false;

At this point I'm basically despairing on a resolution. If I could even just find a way to force the view to re-align all of the column data with the headers (which are correct), then that would fix it.


14 Mar 2014, 10:39 AM
To elaborate on the issue, here are images of the problem:

All columns visible

Column hidden -- displays correctly

Column hidden -- restore state without suspend layout -- hidden (sort of) shows

Column hidden -- restore state with suspend layout -- header correct and correct data shown, but data columns don't line up with headers

Really I feel like I'm pretty close here and just need some way to tell the view to recalculate such that it lines up with the headers. I've obviously tried doLayout and variations, but haven't had any success.

I could possibly try a solution where instead of reconfigure I completely destroy the grid and recreate it after retrieving the configuration from the server. However, I don't like this solution because it means the use of an over-nested layout and/or poor encapsulation since the grid wouldn't then be able to initialize itself.

15 Mar 2014, 6:08 AM
No, we've taken the destroy/re-create approach instead.