1. #1
    Sencha User
    Join Date
    Jan 2008
    Location
    Taiwan
    Posts
    16
    Vote Rating
    11
    Petrushka will become famous soon enough

      0  

    Default 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 :$

  2. #2
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,483
    Vote Rating
    35
    Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    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.Component

  3. #3
    Sencha User
    Join Date
    Mar 2007
    Posts
    461
    Vote Rating
    1
    JorisA is on a distinguished road

      0  

    Default


    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
    Code:
    {
        xtype:'fieldset',
        title: 'Phone Number',
        items :[{
    			xtype: 'textfield',
                fieldLabel: 'Home',
                name: 'home',
            },{
    			xtype: 'textfield',			
                fieldLabel: 'Business',
                name: 'business'
            }
        ]
    }
    you can do
    Code:
    {
        xtype:'fieldset',
        title: 'Phone Number',
        defaultType: 'textfield',
        items :[{
                fieldLabel: 'Home',
                name: 'home',
            },{
                fieldLabel: 'Business',
                name: 'business'
            }
        ]
    }
    A list of all possible xtypes is in the API: Ext.Component

    Edit: DAMM YOU ANIMAL!!! :P

  4. #4
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,483
    Vote Rating
    35
    Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    No, your post added a bit extra necessary info!

  5. #5
    Sencha User
    Join Date
    Jan 2008
    Location
    Taiwan
    Posts
    16
    Vote Rating
    11
    Petrushka will become famous soon enough

      0  

    Default


    Thanks for your explanations!

    Now I understand what "defaultType" is used for. ^^"

  6. #6
    Sencha User chrizmaster's Avatar
    Join Date
    Feb 2009
    Location
    Australia
    Posts
    441
    Vote Rating
    1
    chrizmaster is on a distinguished road

      0  

    Default


    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 )

  7. #7
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,251
    Vote Rating
    73
    Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold

      0  

    Default


    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').

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar