extjs - Dynamically add xtype items to the panel with slidenavigatoin -
so i'm trying put items dynamically panel has slidenavigation feature:
// flyoutnavigation.js ext.define("apn.view.flyoutnavigation", { id: "flyoutnavigationpanel", extend: 'ext.ux.slidenavigation.view', here initialisation of view in view:
// mainviewcontainer.js this.home = "some var" this.flyout = ext.create('apn.view.flyoutnavigation', { id: 'flyoutnavigationpanel', home: this.home }); than i'm trying use variable in this.config.items section, doesn't work, seems sencha compiles first , initialiases components, might wrong, i'm new sencha framework.
so here view home variable used:
ext.define("apn.view.flyoutnavigation", { id: "flyoutnavigationpanel", extend: 'ext.ux.slidenavigation.view', xtype: 'flyoutnavigation', requires: [ ... heaps of things omitted ... ], initialize: function () { this.callparent(); this.setupdynamicitems(); }, config: { items: [ { itemid: 'nav_home', id: 'homeview', items: [{ xtype: 'articlelist', id: 'latestnews', feedurlname: this.home, // - that's place undefined occurs flex: 1 } ], }, so this.home undefined...
one possible solution comming question: how dynamically create xtype templates in sencha touch
i decided put code in this.config.items.add({ ... items ... }) ext.ux.slidenavigation.view looks gave me bug! :( initialise method occurs after binding methods on items of flyoutnavigation view.
here message of bug: uncaught typeerror: cannot read property 'raw' of undefined view.js:310 line: if (ext.isfunction(item.raw.handler)) {
so questions be
- how instance variable in config.items section? if that's possible, ok
- or know work around of issue?
thanks
i don't think can use this.config when defining class, instead can use initialize function told earlier. should able this:
initialize : function() { var me = this; var home = me.config.home; me.add({ itemid: 'nav_home', id: 'homeview', items: [{ xtype: 'articlelist', id: 'latestnews', feedurlname: home, flex: 1 } ], }); } or if have defined homeview in parent class, can this:
initialize : function() { var me = this; var home = me.config.home; me.down('#homeview').add({ xtype: 'articlelist', id: 'latestnews', feedurlname: home, flex: 1 }); }
Comments
Post a Comment