User
User

Reputation: 1

Problem with dynamically adding element to formField Extjs 2

I Have a fieldset inside a FormPanel. I am adding an element to 'fieldset' dynamically. But this element is getting added at the bottom of 'fieldset'where as I want to add this element as a first element of my 'fieldset' i.e. on the top. How can I do that? Can someone help me?

My code for 'fieldset':

      var List = {
        xtype :'fieldset',
        id :'List',
        title :List,
        autoHeight :true,
        items : [ 
        {
            xtype :'button',
            id :'save',
            text :save,
            handler : function() {
              ......
            }
        }, 
        grid ]
    };

Code to add element:

    Ext.getCmp('List').add(
        {
            html :'Error'
        });
   Ext.getCmp('panel').doLayout();       

Thanks...

Upvotes: 0

Views: 1052

Answers (1)

Abdouf
Abdouf

Reputation: 11

Try to use the insert(index,component) function:

Ext.getCmp('List').add(
              yourCompnent
        );
Ext.getCmp('List').insert(0,yourCompnent);

Ext.getCmp('panel').doLayout(); 

Upvotes: 1

Related Questions