Ext code snippets allowing you to set the cursor to a text field when you pop-up a form or window

Just found these and thought they may be useful to someone out there. The situation is this, you have a form that pops up when you click a button and you want to focus the cursor on the first input field in the form so they can start typing right away. This is a common user request by the way. Fortunately, the code to do this is pretty easy. After the form show() call just place the following line and your cursor will be where you want it to be.

	Ext.getCmp('the_name_of_your_text_field').focus('', 10);  

One thought on “Ext code snippets allowing you to set the cursor to a text field when you pop-up a form or window”

  1. Hello,

    I am new to ExtJS and need to make the company application built in ExtJS to do this as well.
    I tried this Ext code snippet and it is not working for me.
    Here is the section of code I am using the snippet in.
    CODE BEGINS
    iWin.doLayout();
    iWin.show(Ext.getBody());

    Ext.getCmp(‘iInvNum’).focus(”, 10);
    CODE ENDS

    Thanks for the help.

Leave a Reply