-
17 Jan 2008 3:45 AM #1
Question about "defaultType" config setting
Question about "defaultType" config setting
Hi, I am a new ExtJS user from Taiwan. I see there are many examples that create a new FormPanel instance always set the "defaultType" config option to "textfield".
After I have read the API documentation's description:
defaultType : String
The default type of container represented by this object as registered in Ext.ComponentMgr (defaults to 'panel').
I still can not understand what it is used for.
Is "defaultType" have to equal "textfield" while I create a new FormPanel? When do I need to set it to other value? And how many options of "defaultType" I can use?
Thanks, if somebody can help me with this question. And this is my first post to a English forum :$
-
17 Jan 2008 4:15 AM #2
If you specify child items of a Panel (using an items Array config) as just a config object with no xtype, then it needs to know what kind of child item to create. FormPanels create TextFields by default.
You can change this for your own Panels.
See the typen ames at the top here: http://extjs.com/deploy/dev/docs/?class=Ext.ComponentSearch the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
17 Jan 2008 4:18 AM #3
Hi Petrushka, it's not that bad for a first post

Ext uses a component model, each component has a xtype so it can be rendered from a json instead of creating all the objects instantly. Here's a good tutorial: http://extjs.com/learn/Ext_2_Overview#Component_XTypes
What it comes down to, is that defaultType specifies the default xtype of all child items, so instead of
you can doCode:{ xtype:'fieldset', title: 'Phone Number', items :[{ xtype: 'textfield', fieldLabel: 'Home', name: 'home', },{ xtype: 'textfield', fieldLabel: 'Business', name: 'business' } ] }
A list of all possible xtypes is in the API: Ext.ComponentCode:{ xtype:'fieldset', title: 'Phone Number', defaultType: 'textfield', items :[{ fieldLabel: 'Home', name: 'home', },{ fieldLabel: 'Business', name: 'business' } ] }
Edit: DAMM YOU ANIMAL!!! :P
-
17 Jan 2008 4:20 AM #4
No, your post added a bit extra necessary info!
Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
17 Jan 2008 4:31 AM #5
Thanks for your explanations!
Now I understand what "defaultType" is used for. ^^"
-
20 Feb 2009 2:52 AM #6
Hey,
I have an additional question to this:
if I use lets say a label, a textfield and a button in one item-array, i am not allowed to set the derfaulttype to "textfield" but have to set the xtype at every component right?
Chriz
(yeah, i still a noob at extjs
)
-
20 Feb 2009 3:23 AM #7Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 41
You can set the defaultType to 'textfield' and specify the xtype of the label and the button (all config objects without an xtype will use xtype:'textfield').


Reply With Quote