1. #1
    Sencha User
    Join Date
    Jan 2013
    Posts
    3
    Vote Rating
    0
    christinaKirkman is on a distinguished road

      0  

    Default Setting focus to checkbox component?

    Setting focus to checkbox component?


    Hi,

    I'm trying to set focus a particular checkbox in a tab of a TabPanel.

    (Some background: The current behavior of the focus allows the user to tab through the fields of all the tabs in the TabPanel, but when you change tabs, the tab index stays the same. For example, if I set focus to the 4th field in tab 1, changed to tab 2 and pressed tab, focus would be set on the 5th field (in this case, checkbox) of the second tab. The goal here is to make the first checkbox have focus when the tab is changed.)

    Code:
    ... new Ext.TabPanel({
                    (...)
                    listeners: {
                        'tabchange' : {
                            fn: ns.events.checkIfOrgTypesTab
                        }
                    }
                })]
    Code:
    ns.events.checkIfOrgTypesTab = function(tabPanel, newTab) {
            var activeTab = tabPanel.getActiveTab();
            var orgTypesTab = tabPanel.findById('orgTypes');
    
            if (activeTab === orgTypesTab) {
                ns.panels.orgTypes.setFocusOnFirstCheckbox();
            }
        };
    (The way I have multiple methods is a bit strange, I know, but that's not what's not working here.)


    Code:
    var setFocusOnFirstCheckbox = function() {
    
            var checkboxes = Ext.getCmp('orgTypeCheckboxGroup').items.items;
            if (checkboxes) {
                checkboxes[0].focus();
            }
        }
    Basically, everything executes like you'd expect, except for that Ext.Component.focus() method, which seems to do nothing. Any ideas? Thanks.

  2. #2
    Sencha User
    Join Date
    Jan 2013
    Posts
    3
    Vote Rating
    0
    christinaKirkman is on a distinguished road

      0  

    Default


    Well, I managed to fix my problem by using .getEl() and Javascript's own .focus() method. Mods can lock this or w/e.