You found a bug! We've classified it as EXTJS-8603 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Ext JS Premium Member GustavR's Avatar
    Join Date
    Jun 2009
    Posts
    37
    Vote Rating
    18
    GustavR will become famous soon enough

      1  

    Default [4.2.0.320] Ext.grid.plugin.HeaderResizer throws error in forceFit with sibling grid

    [4.2.0.320] Ext.grid.plugin.HeaderResizer throws error in forceFit with sibling grid


    REQUIRED INFORMATION
    Ext version tested:
    • Ext 4.2.0.320
    Description:
    • When having two grids, first with forceFit: true, second grid not rendered, the header resizer plugin throws an error when used on last column
    Steps to reproduce the problem:
    • Create two grids, first with forceFit: true, second one not yet rendered but created
    • Click/drag on header resizer of last column on visible grid
    The result that was expected:
    • You can resize the column all you want
    The result that occurs instead:
    • Uncaught TypeError: Cannot call method 'getWidth' of undefined
    Test Case:
    Code:
    var s = Ext.create('Ext.data.ArrayStore', {
        fields: ['dummy'],
        
        data: []
    });
    
    var gridConfig = {
        store: s,
        forceFit: true,
        
        columns: [{
            dataIndex: 'dummy',
            text: 'Dummy',
            flex: 1
        }]
    };
    
    var g = Ext.create('Ext.grid.Panel', gridConfig);
    
    Ext.create('Ext.container.Container', {
        renderTo: Ext.getBody(),
        width: 200,
        height: 200,
        
        layout: {
            type: 'card',
            deferredRender: true
        },
        
        items: [g, Ext.create('Ext.grid.Panel', gridConfig)]
    });
    
    var headerCt = g.headerCt,
        gridColumn = headerCt.getGridColumns()[0],
        headerResizer = headerCt.plugins[0];
        
    // set drag header to simulate click on resize
    headerResizer.dragHd = gridColumn;
    
    headerResizer.getConstrainRegion(); // throws error


    HELPFUL INFORMATION

    Possible fix:
    Code:
    Ext.define('Ext.fix.grid.plugin.HeaderResizer', {
        override: 'Ext.grid.plugin.HeaderResizer',
        
        getConstrainRegion: function() {
            var me       = this,
                dragHdEl = me.dragHd.el,
                nextHd;
    
            // If forceFit, then right constraint is based upon not being able to force the next header
            // beyond the minColWidth. If there is no next header, then the header may not be expanded.
            if (me.headerCt.forceFit) {
                nextHd = me.dragHd.nextSibling('gridcolumn:not([hidden]):not([isGroupHeader])');
            }
    
            return me.adjustConstrainRegion(
                Ext.util.Region.getRegion(dragHdEl),
                0,
                me.headerCt.forceFit ? (nextHd ? nextHd.getWidth() - me.minColWidth : 0) : me.maxColWidth - dragHdEl.getWidth(),
                0,
                me.minColWidth
            );
        }
    });
    Explanation
    Was: me.dragHd.nextNode — Returns first column of second grid
    Now: me.dragHd.nextSibling — Returns null

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,632
    Vote Rating
    817
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Thanks for the report! I have opened a bug in our bug tracker.

  3. #3
    Ext JS Premium Member GustavR's Avatar
    Join Date
    Jun 2009
    Posts
    37
    Vote Rating
    18
    GustavR will become famous soon enough

      0  

    Exclamation


    Woa! Today I tried updating to ExtJs 4.2.1 (4.2.1.883) and to my big surprise the Unit Test I've written for this bug failed!

    How could that happen? Have you not written one of your own, as I even supplied you with a ready to use Test Case?

    In version 4.2.1.744 you fixed this bug with following code change:
    Code:
    if (me.headerCt.forceFit) {
        nextHd = me.dragHd.nextNode('gridcolumn:not([hidden]):not([isGroupHeader])');
        if (!me.headerInSameGrid(nextHd)) {
            nextHd = null;
        }
    }
    As far as good. I was happely disabling my fix as I updated to 4.2.1.744.

    Then 4.2.1.883 came along and some not so clever guy changed the lines concerned to:
    Code:
    if (me.headerCt.forceFit) {
        nextHd = me.dragHd.nextNode('gridcolumn:not([hidden]):not([isGroupHeader])');
        if (nextHd) {
            if (!me.headerInSameGrid(nextHd)) {
                nextHd = null;
            }
            rightAdjust = nextHd.getWidth() - me.minColWidth;
        }
    }
    Two lines above of the new line is the reason why this will never work if _nextHd_ is not in the same grid. How could this be overseen whilst adding this line? It is not like the _nextHd = null_ is many lines above and could be easily overseen, no: it's directly above.

    And lastly with my provided fix this would not have happened:
    Code:
    if (me.headerCt.forceFit) {
        nextHd = me.dragHd.nextSibling('gridcolumn:not([hidden]):not([isGroupHeader])');
        if (nextHd) {
            rightAdjust = nextHd.getWidth() - me.minColWidth;
        }
    }
    Why do you not create a Unit Test per Bug reported to you?
    Is there any way we could help you there? E.g. by providing more information on a valid Test Case to support you in writing a Unit Test?
    Reoccurence of a Bug that can be easiliy programatically tested against is a shame.

  4. #4
    Sencha Premium Member harrydeluxe's Avatar
    Join Date
    Jul 2007
    Location
    Nürnberg, Germany
    Posts
    78
    Vote Rating
    29
    harrydeluxe has a spectacular aura about harrydeluxe has a spectacular aura about

      0  

    Default


    Please open a new bug in your bug tracker.
    DELACAP | Github
    "don't code today what you can't debug tomorrow"

  5. #5
    Ext JS Premium Member GustavR's Avatar
    Join Date
    Jun 2009
    Posts
    37
    Vote Rating
    18
    GustavR will become famous soon enough

      1  

    Default


    Bug still exists in 4.2.2.1144

  6. #6
    Sencha Premium Member joshua.ball@osi.com's Avatar
    Join Date
    Nov 2012
    Location
    Sacramento, CA
    Posts
    43
    Vote Rating
    1
    joshua.ball@osi.com is on a distinguished road

      0  

    Default +1 to GustavR

    +1 to GustavR


    I have also observed this behavior when the "getWidth" function of grid column headers, option lists, and tooltips are called. For me, this happened in the upgrade from 4.2.0 to 4.2.1. I will open a sepparate bug and provide testing files, but please do not treat this as a fixed bug. There is still work to be done here.

    For me, the error is caught and handled without producing a runtime error (EDIT: RUNTIME ERROR OCCURS ANY TIME THE GETWIDTH FUNCTION IS CALLED ON THE PLUGIN/VIEWS REPORTED. I NOTICED THIS IN A CUSTOM SAVESTATE FUNCTION FOR A VIEW WHEN SOMEONE REPORTED THAT THEY COULDN'T SAVE THEIR STATE ANYMORE!), but the error is still logged to the console in the dev codebase. In the prod codebase, the error is simply not logged to the console. Definitley some internal logic that is not quite working as expected.

    Thanks,

    -Josh
    Last edited by joshua.ball@osi.com; 22 Oct 2013 at 4:06 PM. Reason: emphasizing need to keep working on this bug

  7. #7
    Sencha Premium Member joshua.ball@osi.com's Avatar
    Join Date
    Nov 2012
    Location
    Sacramento, CA
    Posts
    43
    Vote Rating
    1
    joshua.ball@osi.com is on a distinguished road

      0  

    Default Likely Related

    Likely Related


    Check out the second comment here:

    http://docs.sencha.com/extjs/4.2.1/#...event-activate

    Please help Sencha folks!

  8. #8
    Sencha Premium Member joshua.ball@osi.com's Avatar
    Join Date
    Nov 2012
    Location
    Sacramento, CA
    Posts
    43
    Vote Rating
    1
    joshua.ball@osi.com is on a distinguished road

      0  

    Default Quick Test

    Quick Test


    Hi All,

    I'm mid project and haven't had a chance to create a use case for you, but here's a quick way to test:
    • Use dev version of ExtJS
    • Create a stateful gridpanel that tracks column resize events
    • Resize a column
    The "saveState" function of the view will inevitably call "getWidth" for each column in the grid.

    This will expose this bug.

    -Josh

  9. #9
    Sencha User
    Join Date
    Jan 2014
    Posts
    1
    Vote Rating
    0
    avitebskiy is on a distinguished road

      0  

    Default Same issue with

    Same issue with


    I'm getting the same error in getConstrainRegion, in 4.2.1. It happens when I have two grids on the same page. me.dragHd.nextNode('gridcolumn:not([hidden]):not([isGroupHeader])') gets the header of the next grid, then me.headerInSameGrid(nextHd) returns false, then nextHd gets set to null, then getWidth() get called and a TypeError exception gets thrown!

    So this:
    Code:
    if (nextHd) {
        if (!me.headerInSameGrid(nextHd)) {
            nextHd = null;
        }
        rightAdjust = nextHd.getWidth() - me.minColWidth;
    }
    Should be something like this:
    Code:
    if (nextHd) {
        if (!me.headerInSameGrid(nextHd)) {
            nextHd = null;
        } else {
            rightAdjust = nextHd.getWidth() - me.minColWidth;
        }
    }