PDA

View Full Version : FormPanel activeItem causes "this.layout.setActiveItem is not a function"?



IvanJ
9 Nov 2009, 3:54 PM
I'm trying to set up a simple form like so:



Ext.onReady(function(){
var form = new Ext.form.FormPanel({
title: "Request Computer Account (Graduate)",
frame: true,
width: 400,
iconCls: "icon-add-user",
activeItem: "FirstName",
items:
{
xtype: "fieldset",
title: "Personal Information",
defaultType: "textfield",
labelAlign: "right",
items:[
{
fieldLabel: "First Name",
id: "FirstName"
},
{
fieldLabel: "Last Name",
id: "LastName"
}
]
}
});


...it works just fine if I remove the activeItem attribute. If I keep it, I get error:

"this.layout.setActiveItem is not a function"

... Any idea why that is? According to API this should work...

MiamiCoder
9 Nov 2009, 8:07 PM
Check out the activeItem config in the docs. This option applies to layouts that can display items one at a time: AccordionLayout, CardLayout and FitLayout.

jcabrera
9 Nov 2009, 8:36 PM
this code should work for you...

Ext.onReady(function(){
var form = new Ext.form.FormPanel({
title: "Request Computer Account (Graduate)",
frame: true,
layout:'form',
renderTo:'container',
width: 400,
iconCls: "icon-add-user",
items:
{
xtype: "fieldset",
title: "Personal Information",
defaultType: "textfield",
labelAlign: "right",
items:[
{
fieldLabel: "First Name",
id: "FirstName"
},
{
fieldLabel: "Last Name",
id: "LastName"
}
]
},
listeners: {
afterlayout :function(){
this.getForm().findField("FirstName").focus();
}
}
});

});

ccording to Api, activeItem only apply to objects who show one item at a time... check next...

/**
* @cfg {String/Number} activeItem
* A string component id or the numeric index of the component that should be initially activated within the
* container's layout on render. For example, activeItem: 'item-1' or activeItem: 0 (index 0 = the first
* item in the container's collection). activeItem only applies to layout styles that can display
* items one at a time (like {@link Ext.layout.AccordionLayout}, {@link Ext.layout.CardLayout} and
* {@link Ext.layout.FitLayout}). Related to {@link Ext.layout.ContainerLayout#activeItem}.
*/

IvanJ
10 Nov 2009, 8:58 AM
Thanks, that worked!