[CLOSED] Enumerating TabPanel instances on the page

  1. #1

    [CLOSED] Enumerating TabPanel instances on the page

    Hi,

    I'm trying to port a segment of code that enumerates TabPanel instances on the page. It's been working well in 1.x and I'd like it to do the same in 2.x. However, the instances of TabPanel are never found. I do realize that the namespaces have changed in 2.x so Ext.TabPanel has become Ext.tab.Panel but this makes no difference. Please advise if more info is required here.

            var tabPanels = [];
    
            callingWindow.Ext.ComponentMgr.all.each(function (c) {
                if (c instanceof callingWindow.Ext.tab.Panel) {
                    tabPanels.push(c);
                }
            });
    Last edited by Baidaly; Aug 07, 2013 at 12:17 AM. Reason: [CLOSED]
  2. #2
    Try to use isXType method
    if (c.isXType("tabpanel")) {
  3. #3
    Thanks for your response Vladimir! I've modified the code segment as below but it never evaluates to "true" or even to not "undefined". c variable is always of String type in this setup unlike in 1.x where it's of actual component type.

            
            var tabPanels = [];
    
            callWnd.Ext.ComponentMgr.all.each(function (c) {
                if (c.isXType && c.isXType("tabpanel")) {
                    tabPanels.push(c);
                }
            });
    Last edited by vadym.f; Aug 06, 2013 at 9:03 PM.
  4. #4
    Try this
    var tabPanels = [],
        all = callWnd.Ext.ComponentMgr.all;
     
    all.each(function (id) {
        var cmp = all.get(id);
        if (cmp.isXType("tabpanel")) {
            tabPanels.push(cmp);
        }
    });
  5. #5
    Greatly appreciated, it works! I've also tried the following workaround that does the same. I don't know which one is more efficient; probably, the each enumerator is better optimized to work with many controls on the page. Would be interested in your take.

            var allControls = callWnd.Ext.ComponentMgr.all.getValues();
            for (var i = 0; i < allControls.length; i++ ) {
                if (allControls[i].isXType && allControls[i].isXType("tabpanel")) {
                    tabPanels.push(allControls[i]);
                }
            }
  6. #6
    In a common case, the "for" loop is more efficient than "each". A function is called for each an item in the "each" case.

    You can see
    Use for (...) rather than Ext.Array.each
    here:
    http://www.sencha.com/blog/ext-js-4-1-performance/
    Last edited by Daniil; Aug 07, 2013 at 12:41 PM.
  7. #7
    Thanks for the insight Daniil!

Similar Threads

  1. Replies: 5
    Last Post: Apr 16, 2012, 9:17 PM
  2. [CLOSED] ids and multiple instances of the same UI
    By PLoch in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jul 28, 2011, 9:44 PM
  3. multiple instances of the same panel
    By costab in forum 1.x Help
    Replies: 3
    Last Post: May 30, 2011, 4:46 PM
  4. Tabpanel Iframe page
    By vali1993 in forum 1.x Help
    Replies: 2
    Last Post: Feb 22, 2010, 3:56 PM
  5. Replies: 2
    Last Post: Jun 19, 2009, 2:49 PM

Tags for this Thread

Posting Permissions