1. #1
    Sencha Premium Member
    Join Date
    Apr 2012
    Location
    Centreville, VA
    Posts
    8
    Vote Rating
    0
    pscalouc is on a distinguished road

      0  

    Default How to listen for Ext.ux.TabReorderer events in controller?

    How to listen for Ext.ux.TabReorderer events in controller?


    Is there anyway to listen for TabReorderer events (Drop, Drag, etc.) inside a controller? If so what would be the syntax for that. I know some plugins add events to the components that they are added to, but I'm thinking from the docs that TabReorderer works differently.

    I am able to get the listeners for TabReorderer to work fine like so:

    Code:
    var tabReordererPlugin = Ext.create('Ext.ux.TabReorderer', {
                listeners: {
                    Drop: function(tabpanel, container, dragCmp, startidx, idx, eOpts) {
                        //Do something
                    }
    }
    });
    It would just be nice to be able to keep all my listener code inside my controllers. Thanks in advance.

  2. #2
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    4,781
    Vote Rating
    167
    slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold

      0  

    Default


    Since the tabReorder events are fired from the tabReorderer itself the only way I could see to do that is after the tabPanel is rendered relay the events from its tabReorderer to itself. Then your controller can listen to the events right from the tabPanel itself.

  3. #3
    Sencha Premium Member
    Join Date
    Apr 2012
    Location
    Centreville, VA
    Posts
    8
    Vote Rating
    0
    pscalouc is on a distinguished road

      0  

    Default


    I was not aware of the relayEvents method. That solved my problem. Thank you slemmon!

  4. #4
    Sencha User
    Join Date
    Jan 2010
    Location
    Northern Ireland
    Posts
    58
    Vote Rating
    2
    Frith is on a distinguished road

      0  

    Default


    Trying to accomplish this via Architect.

    I have successfully included the reorderer plugin using:

    Code:
    Ext.define('BRM.view.override.SectionsTabPanel', {    override: 'BRM.view.SectionsTabPanel'
    
    
    }, function() {
        Ext.override(BRM.view.SectionsTabPanel, {
            initComponent:function(){            
                this.plugins=[Ext.create('Ext.ux.TabReorderer')];
                this.callOverridden(arguments);
                this.plugins[0].relayEvents(this,['Drag','Drop','ChangeIndex']); // <-- this has no effect
            }
        });
    });
    Could you post some example code?

  5. #5
    Sencha Premium Member
    Join Date
    Apr 2012
    Location
    Centreville, VA
    Posts
    8
    Vote Rating
    0
    pscalouc is on a distinguished road

      0  

    Default


    Here are some code snippets for how I did it. Hopefully you'll find it helpful.

    Code:
    // I had this code in the initComponent of a panel that contained my tab panel
    var tabReordererPlugin = Ext.create('Ext.ux.TabReorderer', {});
    var logTabPanel = Ext.create('widget.tabpanel', {
                region: 'center',
                itemId: 'logTabPanel',
                plugins: [tabReordererPlugin]
            });
    logTabPanel.relayEvents(tabReordererPlugin, ['Drop']);
    
    // Then in my controller I had something like this
    'tabpanel#logTabPanel': {
      beforetabchange: this.handleLogTabPanelTabChange,
      remove: this.handleLogTabPanelTabRemove,
      // Drop is a relayed event from TabReorderer
      Drop: this.handleLogTabPanelDrop
    },

  6. #6
    Sencha User
    Join Date
    Jan 2010
    Location
    Northern Ireland
    Posts
    58
    Vote Rating
    2
    Frith is on a distinguished road

      0  

    Default




    RTFM:

    object.relayEvents(source, [events])

    NOT source.relayEvents(sink, [events]) !!!!

    Code:
    Ext.define('BRM.view.override.SectionsTabPanel', {    override: 'BRM.view.SectionsTabPanel'
    
    
    }, function() {
        Ext.override(BRM.view.SectionsTabPanel, {
            initComponent:function(){            
                this.plugins=[Ext.create('Ext.ux.TabReorderer')];
                
                this.relayEvents(this.plugins[0],['Drag','Drop','ChangeIndex']); // <--- This works
                
                this.callOverridden(arguments);
                
            }
        });
    });


  7. #7
    Sencha Premium Member
    Join Date
    Apr 2012
    Location
    Centreville, VA
    Posts
    8
    Vote Rating
    0
    pscalouc is on a distinguished road

      0  

    Default


    I just noticed that in your code after I posted. I'm glad I could help you out.

Thread Participants: 2