Results 1 to 2 of 2

Thread: TabScrollerMenu tweaks

  1. #1
    Sencha User
    Join Date
    Feb 2008
    Posts
    23
    Vote Rating
    2
      0  

    Default TabScrollerMenu tweaks

    A couple of small things popped up on this nice little plugin. First, when the tabpanel has fewer tabs than the value specified for menu pageSize, no menu is built at all. The plugin code tries to avoid adding the active tab AND any hidden tabpanel children to the menu. I think the assumption was that all tabs would be visible in this case. But if the tabpanel is in a window or another pane whose width is such that some tabs are hidden, it would be helpful to have all tabs in the dropdown menu. To change the default behavior I changed function generateTabMenuItems (around line ~200) from this:
    Code:
            else {
                tabPanel.items.each(function(item) {
                	if (item.id != curActive.id && !item.hidden) {
                        me.tabsMenu.add(me.autoGenMenuItem(item));
                    }
                });
            }
    to this:
    Code:
            else {
                tabPanel.items.each(function(item) {
                	me.tabsMenu.add(me.autoGenMenuItem(item));
                });
            }
    In addition, I found an edge case bug. It is unlikely to be seen by most, but I'm including this description just in case. I was working with some mock data that had an 'id' field in each row, and the values of 'id' were integers starting with one (1). I used this data to build a set of tabs, assigning each tab the id of the record's 'id'. Doing this caused the first value in the tabscrollermenu to be duplicated. The reason is that the use of tabPanel.items.get sees a record having an id value of '1', which is actually the first record and was already added to the tree under index 0. This behavior is avoided by directly referencing the items.items array within the tabpanel. This change is at line 168.
    Code:
    for (x = 0; x < pageSize; x++) {
       index = x + curPage - pageSize;
    
       //item = tabPanel.items.get(index);
       item = tabPanel.items.items[index];  
                        
       menuItems.push(me.autoGenMenuItem(item));
    }
    Last edited by Buzzwords; 25 Nov 2011 at 10:34 AM. Reason: clarified that tabs were built from store data

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,551
    Vote Rating
    1271
      0  

    Default

    Nice job!
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

Tags for this Thread

Posting Permissions

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