Now I wanted to set the default focus in a FormPanel that is not in a Window. Event to use was afterlayout and it seems that sometimes you need to delay the focus a little bit.
I needed to set the focus to a field in an Ext.Window that contains a FormPanel. Turns out to be really simple, even though it took me awhile to find it…. use the defaultButton config on Ext.Window. It is poorly named, b/c it can be any component, not just a button.
Ext JS 4 Update
Looks like defaultButton is gone and now Ext.window.Window has the more helpfully named field “defaultFocus”. And, straight from the docs:
Specifies a Component to receive focus when this Window is focused.
This may be one of:
- The index of a footer Button.
- The id or Ext.AbstractComponent.itemId of a descendant Component.
- A Component.