Best Practices concerning initComponent() in Ext.define()

前端 未结 3 1980
广开言路
广开言路 2020-12-13 07:05

I\'m writing all my components in ExtJS\'s new MVC fashion using Ext.define().

I struggle a bit whether define properties inside of initComponent(

3条回答
  •  伪装坚强ぢ
    2020-12-13 07:44

      Ext.define('My.Group', {
    // extend: 'Ext.form.FieldSet',
    xtype : 'fieldset',
    config : {
        title : 'Group' + i.toString(),
        id : '_group-' + i.toString()
    
    },
    constructor : function(config) {
        this.initConfig(config);
    
        return this;
    },    
    collapsible: true,
    autoScroll:true,
    .....
    });
    

    you can use it as follow.

    handler : function() {                      
            i = i + 1;
            var group = new My.Group({
                title : 'Group' + i.toString(),
                id : '_group-' + i.toString()
            });
            // console.log(this);
            // console.log(group);
            Ext.getCmp('panelid').insert(i, group);
            Ext.getCmp('panelid').doLayout();
        }
    

提交回复
热议问题