Set focus on Extjs textfield

后端 未结 11 1812
星月不相逢
星月不相逢 2020-12-31 02:02

Currently I got problem with setting focus on extjs textfield. When form show, I want to set focus to First name text box and I try to use build in function focus() but stil

11条回答
  •  孤独总比滥情好
    2020-12-31 02:18

    That works for me. In textfield or textarea add listeners config:

    listeners:{
                afterrender:'onRender'
            }
    

    After, in your controller write function:

    onRender:function(field){
        Ext.defer(()=>{
            field.focus(false,100);
        },1);
    }
    

    Ext.defer is wrap for setTimout(). Without Ext.defer() field.focus() doesn't work and i don't why. You cant write that function in listeners config instead of using controller's function name, but good practice is hold functions in component's controller. Good luck.

提交回复
热议问题