javascript - How could I create a component in this way? -


i'd create component, tabpanel, treepanel, or gridpanel, inherited base object, base object extends ext.container.container, , pass config parameters it. how make happen?

i've tried below, won't work.

ext.define('myproj.base.component', { extend: 'ext.container.container', requires:[     'ext.tab.*',     'ext.tree.*',     'ext.grid.*',     'ext.form.*',     'ext.data.store' ],  //position, size, css decoration layout: 'accordion', //region: '', width: null, height: null, //html: ' ', //bodypadding: null,  //operation collapsible: true, closable: false, draggable: false, floatable: true, autoscroll: true,  //data store: null, //items: null,  initcomponent : function(){     var me = this;      me.callparent(arguments); },  constructor: function(cfg, defaulttype){     var me = this;     me.xtype = 'tabpanel';     me.defaulttype = defaulttype;     me.basecls = ext.basecssprefix+defaulttype;     me.componentcls = ext.basecssprefix+defaulttype;     ext.apply(me, cfg || {});      me.callparent(); }   }); 

this not way can create component.

first of all, tab panel, grid , tree panel inherit ext.container.container. must not extend class, 1 of child classes.

then, must not use constructor do.

unfortunately not clear @ want achieve. imagine create tab panel 2 tabs, 1 grid, , other tree, or similar.

you achieve code follows :

ext.define('myproj.base.component', {     extend: 'ext.tab.panel', // layout: 'accordion'  // tab panel cannot have accordion layout      items: [{         xtype: 'grid',          ...      }, {         xtype: 'treepanel',          ...      }],      collapsible: true,     closable: false,     draggable: false,     floatable: true,     autoscroll: true, 

})

i hope helps come closer use framework way intended.

if didn't want do, please try reformulate question such more clear.

edit

according explanation (you gave answer , deleted meanwhile), try create function can return of components. there no reason implement this.

if have special myproj.base.tabpanel , want ot instatiate, have use ext.widget. add alias component,

ext.define('myproj.base.tabpanel', {     extend: 'ext.tab.panel',     alias: 'widget.myproj-tab' 

you can reference component anywhere xtype: 'myproj-tab', , create instance ext.widget('myproj-tab'). function wanted achieve. there no need reinvent wheel. build-in.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -