-
16 Aug 2012 10:24 AM #1
Answered: dynamically add content to list
Answered: dynamically add content to list
I'm trying to dynamically add content to a list, but for some reason I never see anything show up when I run this code, and I have no idea why. Any help?Code:Ext.define("GS.view.Main", { extend: 'Ext.Container', xtype: 'main', config: { items: [ { xtype: 'list', itemTpl: '{name}', initialize: function() { this.callParent( arguments ); var store = Ext.create( 'Ext.data.Store', { fields: [ 'name' ] } ); store.add( { name: 'test' } ); this.setStore( store ); } } ] } });
-
Best Answer Posted by jerome76
You can only use the initialize function when defining your own subclass. Check out this demo. It works there.
-
16 Aug 2012 11:04 AM #2
You can only use the initialize function when defining your own subclass. Check out this demo. It works there.
-
16 Aug 2012 3:57 PM #3
Thanks, that worked well. Do you know if it says anywhere in the documentation that you can only overwrite initialize when defining a class?
-
16 Aug 2012 4:09 PM #4
Well you can only overwrite if you are defining a subclass. When you use the shortcut like { xtype: '...', ... } you are basically calling Ext.create(), not Ext.define().
Maybe you can use something like a listener for an 'init' event but I just stick with definitions.


Reply With Quote