Results 1 to 9 of 9

Thread: Grid ApplyState column hidden then unhidden - data shows, but no header

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Ext JS Premium Member mcouillard's Avatar
    Join Date
    Jun 2008
    Location
    Bucks County, PA
    Posts
    119

    Exclamation Grid ApplyState column hidden then unhidden - data shows, but no header

    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:
    https://fiddle.sencha.com/#fiddle/19r

  2. #2
    Ext JS Premium Member mcouillard's Avatar
    Join Date
    Jun 2008
    Location
    Bucks County, PA
    Posts
    119

    Default

    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.

  3. #3
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,256

    Default

    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.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  4. #4
    Ext JS Premium Member mcouillard's Avatar
    Join Date
    Jun 2008
    Location
    Bucks County, PA
    Posts
    119

    Default

    Yes, just like this recent related thread:
    http://www.sencha.com/forum/showthre...mns-are-hidden

    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).

  5. #5
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,256

    Default

    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.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  6. #6
    Ext JS Premium Member mcouillard's Avatar
    Join Date
    Jun 2008
    Location
    Bucks County, PA
    Posts
    119

    Default

    OK

    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.

  7. #7
    Sencha Premium Member
    Join Date
    Aug 2007
    Posts
    26

    Default Same Problem -- Any Luck?

    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).

    Code:
            this.suspendLayout = true;
            this.reconfigure(this.getStore(), columns);
            this.stateId = 'record-grid-' + this.entity;
            this.initState();
            this.suspendLayout = false;
            this.doLayout();
    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.

    Thanks

  8. #8
    Sencha Premium Member
    Join Date
    Aug 2007
    Posts
    26

    Default Images for Reference

    To elaborate on the issue, here are images of the problem:

    All columns visible
    all-columns.png

    Column hidden -- displays correctly
    hidden-column-good.png

    Column hidden -- restore state without suspend layout -- hidden (sort of) shows
    hidden-column-header-bad.png

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

    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.

  9. #9
    Ext JS Premium Member mcouillard's Avatar
    Join Date
    Jun 2008
    Location
    Bucks County, PA
    Posts
    119

    Default

    No, we've taken the destroy/re-create approach instead.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •