1. #1
    Sencha Premium Member rpiwonka's Avatar
    Join Date
    Jul 2007
    Posts
    29
    Vote Rating
    0
    rpiwonka is on a distinguished road

      0  

    Default [2.3.0] Grid Row Click runtime error

    [2.3.0] Grid Row Click runtime error


    Ext. 2.2.1 and Ext 2.3.0
    Browser: didn't matter

    We have three grids all sharing the same store. The first grid is a paged grid, the other two are not. This error occurs on the two "sub" grids.

    When the user clicks on the first row the click event fires and everyone is happy, however if the user clicks on row 2-n then a runtime error occurs in Ext.grid.GridView getRow method. It seems that under these circumstances the row parameter is NaN.

    I traced the call stack back and found that in this method the call to this.syncFocusEl does not pass all the parameters:

    Code:
    focusCell : function(row, col, hscroll){
            this.syncFocusEl(this.ensureVisible(row, col, hscroll));
            if(Ext.isGecko){
                this.focusEl.focus();
            }else{
                this.focusEl.focus.defer(1, this.focusEl);
            }
        }
    Here is my fix:
    Code:
    focusCell : function(row, col, hscroll){
    		this.syncFocusEl(row, col, this.ensureVisible(row, col, hscroll));
            if(Ext.isGecko){
                this.focusEl.focus();
            }else{
                this.focusEl.focus.defer(1, this.focusEl);
            }
        }
    I am usure if the code that broke in our situtation is unusual or if the as built code intends to pass the results of ensureVisible, an XY coordinate, to the syncFocusEl method.

    Can someone let me know if I did the correct fix?

    Thanks.

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


    Can you post an example that demonstrates the problem.

    (your solution isn't correct - syncFocusEl also allows a single array parameter)

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


    You could run into problems if you try to focus a row that isn't in the grid.

    You can solve that with:
    Code:
    Ext.override(Ext.grid.GridView, {
        syncFocusEl : function(row, col, hscroll){
            var xy = row;
            if(xy !== undefined && !Ext.isArray(xy)){
                row = Math.min(row, Math.max(0, this.getRows().length-1));
                xy = this.getResolvedXY(this.resolveCell(row, col, hscroll));
            }
            this.focusEl.setXY(xy||this.scroller.getXY());
        }
    });

Thread Participants: 1