jmariani
1 Dec 2008, 5:28 PM
Hi.
I needed to set the focus to the first field on a form when it's shown, so I developed this small plugin to do that.
The only thing I couldn't figure how to fix is the field to be validated when it get the focus.
Hope it helps somebody.
bdApp.formAutoFocus = function (){
return{
init : function (form){
//Try to get the first focusable field.
form.on('afterlayout', function(){
Ext.each(this.items.items,
function(item, index, allItems){
switch (item.getXType()) {
case 'hidden':
return true;
break;
default:
if (!item.disabled) {
item.suspendEvents();
item.focus(true, true);
//item.clearInvalid();
item.resumeEvents();
return false;
}
}
}
);
});
}
}
};
Cya.
I needed to set the focus to the first field on a form when it's shown, so I developed this small plugin to do that.
The only thing I couldn't figure how to fix is the field to be validated when it get the focus.
Hope it helps somebody.
bdApp.formAutoFocus = function (){
return{
init : function (form){
//Try to get the first focusable field.
form.on('afterlayout', function(){
Ext.each(this.items.items,
function(item, index, allItems){
switch (item.getXType()) {
case 'hidden':
return true;
break;
default:
if (!item.disabled) {
item.suspendEvents();
item.focus(true, true);
//item.clearInvalid();
item.resumeEvents();
return false;
}
}
}
);
});
}
}
};
Cya.