1. #1
    Sencha User
    Join Date
    Jun 2011
    Posts
    2
    Vote Rating
    0
    codydjango is on a distinguished road

      0  

    Default stopEvent, stopPropagation not working as expected.

    stopEvent, stopPropagation not working as expected.


    I have an columngrid with two columns: the second is an actioncolumn.


    I'd like it so that a click on the column is passed to the click handler, unless the user clicks on an action in the action column.


    I implemented e.stopEvent() in the actioncolumn handlers. This has no effect. The event first triggers the clicked-upon action handler, then triggers the column handler, then triggers the rowclick handler, despite e.stopEvent in each handler. I'm using the default Ext scoping scheme.


    Can someone explain why this is happening? Could there be Ext 3.4 options for how event bubbling is handled?


    Thanks.

  2. #2
    Sencha - Community Support Team sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,333
    Vote Rating
    85
    sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough

      0  

    Default no way, need to overwrite

    no way, need to overwrite


    Hi,

    I checked ActionColumn definition and found this:

    Code:
    processEvent: function (name, e, grid, rowIndex, colIndex) {
            var m = e.getTarget().className.match(this.actionIdRe),
                item, fn;
            if (m && (item = this.items[parseInt(m[1], 10)])) {
                if (name == 'click') {
                    (fn = item.handler || this.handler) && fn.call(item.scope || this.scope || this, grid, rowIndex, colIndex, item, e);
                } else if ((name == 'mousedown') && (item.stopSelection !== false)) {
                    return false;
                }
            }
            return Ext.grid.ActionColumn.superclass.processEvent.apply(this, arguments);
        }
    Looks like there is nothing to check if handler returns false or something. So we need to overwrite it:

    Code:
    Ext.override(Ext.grid.ActionColumn, {
        processEvent : function(name, e, grid, rowIndex, colIndex){
            var m = e.getTarget().className.match(this.actionIdRe),
                item, fn;
            if (m && (item = this.items[parseInt(m[1], 10)])) {
                if (name == 'click') {
                    fn = item.handler || this.handler;
                    if(fn){
                        if(fn.call(item.scope || this.scope || this, grid, rowIndex, colIndex, item, e) === false){
                            return false;
                        }
                    }
                } else if ((name == 'mousedown') && (item.stopSelection !== false)) {
                    return false;
                }
            }
            return Ext.grid.ActionColumn.superclass.processEvent.apply(this, arguments);
        }
    });
    or

    Code:
    {
    xtype: 'actioncolumn', .... processEvent : function(name, e, grid, rowIndex, colIndex){ var m = e.getTarget().className.match(this.actionIdRe), item, fn; if (m && (item = this.items[parseInt(m[1], 10)])) { if (name == 'click') { fn = item.handler || this.handler; if(fn){ if(fn.call(item.scope || this.scope || this, grid, rowIndex, colIndex, item, e) === false){ return false; } } } else if ((name == 'mousedown') && (item.stopSelection !== false)) { return false; } } return Ext.grid.ActionColumn.superclass.processEvent.apply(this, arguments); }
    }
    And 'return false' would cancel your click event.

    Regards.
    Last edited by sword-it; 6 Jul 2012 at 7:41 AM. Reason: misspelling
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

  3. #3
    Ext JS Premium Member
    Join Date
    Apr 2008
    Posts
    359
    Vote Rating
    16
    rich02818 will become famous soon enough

      0  

    Default


    Has this been logged into the problem system for v3.4? What is the assigned number? Will this fix be in 3.4.1?