1. #1
    Sencha User
    Join Date
    Nov 2012
    Posts
    100
    Vote Rating
    0
    newusername is on a distinguished road

      0  

    Default adding items

    Hi,

    I have simple code written in ext js 3.4

    Code:
    Ext.onReady(function()
            {
        var myForm = Ext.extend(Ext.FormPanel,{
                width : 100,
                height : 200,
                items : [ 
                         {
                                fieldLabel : 'First Name',
                                xtype : 'textfield',
                                name : 'FName',
                                allowBlank : false
                            }
    
    
                        ], 
                 initComponent: function(){
                    this.title = 'Login Form';
                   /*this.items : [                      {
                                fieldLabel : 'First Name',
                                xtype : 'textfield',
                                name : 'FName',
                                allowBlank : false
                            }
    
    
                        ];*/
                    myForm.superclass.initComponent.call(this);
                }
    
                    
                });
                
                
                
                var f = new myForm();
                f.render(document.body);
            });
    In this code 'items' property is added outside of initComponent function. If I add same property within initComponent and uncomment the code then component is get rendered. I really not able to understand what is happening here..

  2. #2
    Sencha User sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,334
    Vote Rating
    87
    sword-it is just really nice sword-it is just really nice sword-it is just really nice sword-it is just really nice

      0  

    Default

    We do not support putting complex objects in the prototype of an extended class. When you do this, the objects will be shared across instances of classes and in essence become static.

    Prior to calling the parent class's initComponent method you can view what is in this. items.

    After invoking the parent class's initComponent method you can view what is in this.items

    You would never be able to set the "Property" items directly.
    You can invoke the "Method" add after the component is setup.

    Check this link for more details:-
    http://www.sencha.com/forum/showthre...ed-Panel-Class
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

Thread Participants: 1