Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Extjs 将自动对焦设置为“下一步”按钮_Extjs_Extjs4_Extjs4.1 - Fatal编程技术网

Extjs 将自动对焦设置为“下一步”按钮

Extjs 将自动对焦设置为“下一步”按钮,extjs,extjs4,extjs4.1,Extjs,Extjs4,Extjs4.1,我在extjs中有一个向导,我在其中放置next、back和cancel按钮。 根据要求,我需要自动设置下一步按钮的焦点。怎么做 buildButtons : function() { return [ { text:'Back', id:'backBtn', hidden:true, autoHeight:true, action: 'Back' }, { text:

我在extjs中有一个向导,我在其中放置next、back和cancel按钮。 根据要求,我需要自动设置下一步按钮的焦点。怎么做

buildButtons : function() {
    return [
    {
        text:'Back',
        id:'backBtn',
        hidden:true,
        autoHeight:true,
        action: 'Back'
    },
    {
        text:'Next',
        id:'nextBtn',
        autoHeight:true,
        hidden:false,
        action: 'Next'
    },
    {
        text:'Finish',
        id:'finishBtn',
        autoHeight:true,
        hidden:false,  // Comments below line if you want finished button on each panel.
        //hidden:true,
        action: 'Finish'
    },
    {
        text:'Cancel',
        id:'cancelBtn',
        autoHeight:true,
        hidden:false,
        action: 'Cancel'
    }
    ];

}

假设您谈论的是最新版本(4.1.1)

获取按钮引用并调用

您应该使用按钮本身或包含按钮的组件的afterrender事件来执行此操作

可直接在其中一个API代码框中执行的示例

编辑以回答评论:

根据给定的信息,我建议您使用config属性来放置按钮。在您的情况下,我建议您使用dockedItems数组而不是便利按钮数组。请尝试以下操作:

dockedItems: [{
    xtype: 'toolbar',
    dock: 'bottom',
    ui: 'footer',
    defaults: {minWidth: minButtonWidth},
    items: [
        {
            text:'Back',
            id:'backBtn',
            hidden:true,
            autoHeight:true,
            action: 'Back'
        },
        {
            text:'Next',
            id:'nextBtn',
            autoHeight:true,
            hidden:false,
            action: 'Next'
        },
        {
            text:'Finish',
            id:'finishBtn',
            autoHeight:true,
            hidden:false,  // Comments below line if you want finished button on each panel.
            //hidden:true,
            action: 'Finish'
        },
        {
            text:'Cancel',
            id:'cancelBtn',
            autoHeight:true,
            hidden:false,
            action: 'Cancel'
        }
    ],
    listeners: {
        afterrender: function(b) {
            b.down('button[action=Next]').focus(false, 100);  
        }
    }
}]

是的,正如@sra所说的,使用类似于:

Ext.getCmp('IdOfNextButton').focus();

或者更好的是,从表单中使用一个向上/向下方法,通过特定类来查找它,而不是依赖Id。

如果可以使用它,更好的方法是使用Ext.window.window的defaultFocus配置。从:

defaultFocus:String/Number/Ext.Component

指定此窗口聚焦时接收聚焦的组件

这可能是以下情况之一:

  • 页脚按钮的索引
  • 子组件的id或Ext.AbstractComponent.itemId
  • 组件
自:4.0.0起提供

Ext.getCmp('IdOfNextButton').focus();