Results 1 to 6 of 6

Thread: [FIXED-653] Bug in GridPanel.processEvent; this.view is null when used

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Ext JS Premium Member
    Join Date
    Feb 2009
    Location
    London, UK
    Posts
    31

    Default [FIXED-653] Bug in GridPanel.processEvent; this.view is null when used

    In GridPanel.processEvent() in 3.1.0 (as opposed to 3.0.3), the view's "processEvent" method is also called. The trouble is that this.view can be reset to null during the execution of the method, causing the this.view.processEvent() call to fail. The fix is simple: use the cached copy of this.view to make the method call (in local variable 'v').

    I.e.
    Code:
        processEvent : function(name, e){
            this.fireEvent(name, e);
            var t = e.getTarget(),
                v = this.view,
                header = v.findHeaderIndex(t);
                
            if(header !== false){
                this.fireEvent('header' + name, this, header, e);
            }else{
                var row = v.findRowIndex(t),
                    cell,
                    body;
                if(row !== false){
                    this.fireEvent('row' + name, this, row, e);
                    cell = v.findCellIndex(t);
                    body = v.findRowBody(t);
                    if(cell !== false){
                        this.fireEvent('cell' + name, this, row, cell, e);
                    }
                    if(body){
                        this.fireEvent('rowbody' + name, this, row, e);
                    }
                }else{
                    this.fireEvent('container' + name, this, e);
                }
            }
     //        this.view.processEvent(name, e);         DON'T DO THIS
            v.processEvent(name, e);                      DO THIS INSTEAD
        },
    Andrew

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246

    Default

    Any event handler could cause the grid to be destroyed, so IMHO a safer solution is to use:
    Code:
    Ext.override(Ext.grid.GridPanel, {
        processEvent : function(name, e){
            this.view.processEvent(name, e);
        }
    });
    Ext.override(Ext.grid.GridView, {
        processEvent : function(name, e){
            var t = e.getTarget(),
                g = this.grid,
                header = this.findHeaderIndex(t);
            g.fireEvent(name, e);
            if(header !== false){
                g.fireEvent('header' + name, g, header, e);
            }else{
                var row = this.findRowIndex(t),
                    cell,
                    body;
                if(row !== false){
                    g.fireEvent('row' + name, g, row, e);
                    cell = this.findCellIndex(t);
                    if(cell !== false){
                        g.fireEvent('cell' + name, g, row, cell, e);
                    }else{
                        body = this.findRowBody(t);
                        if(body){
                            g.fireEvent('rowbody' + name, g, row, e);
                        }
                    }
                }else{
                    g.fireEvent('container' + name, g, e);
                }
            }
        }
    });
    Ext.override(Ext.grid.GroupingView, {
        processEvent: function(name, e){
            Ext.grid.GroupingView.superclass.processEvent.call(this, name, e);
            var hd = e.getTarget('.x-grid-group-hd', this.mainBody);
            if(hd){
                var field = this.getGroupField(),
                    prefix = this.getPrefix(field),
                    groupValue = hd.id.substring(prefix.length);
                groupValue = groupValue.substr(0, groupValue.length - 3);
                if(groupValue){
                    this.grid.fireEvent('group' + name, this.grid, field, groupValue, e);
                }
            }
        }
    });

  3. #3
    Sencha User
    Join Date
    Jan 2008
    Location
    Toronto, Canada
    Posts
    481

    Default

    Just bumping this thread. This defect deserves attention.

  4. #4
    Sencha User Jamie Avins's Avatar
    Join Date
    Mar 2007
    Location
    Redwood City, California
    Posts
    3,661

    Default

    [type]: fix
    [module]: Grid
    [id]: #653
    [desc]: Fixed #653. ProcessEvent moved to GridView and called from GridPanel. This will allow the view to dynamically change during and event and still function properly.

  5. #5
    Sencha Premium User mynameisyoda's Avatar
    Join Date
    Mar 2008
    Location
    Turin, Italy
    Posts
    14

    Default what SVN version?

    Please in what SVN version is the Fix? in 3.1.2 the problem still persists (with our code at least...)
    Sergio - Ext addict
    -----------------------------
    may the force be with you

  6. #6
    Sencha User Jamie Avins's Avatar
    Join Date
    Mar 2007
    Location
    Redwood City, California
    Posts
    3,661

    Default

    SVN 6235 for the 3.2.x branch since it was a major code shift between classes.

Posting Permissions

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