Results 1 to 4 of 4

Thread: dynamically add content to list

  1. #1
    Sencha User
    Join Date
    Jun 2012
    Posts
    52
    Answers
    4
    Vote Rating
    2
      0  

    Default Answered: dynamically add content to list

    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 );
    			}
    		}
    		]
        }
    });
    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?

  2. You can only use the initialize function when defining your own subclass. Check out this demo. It works there.

  3. #2
    Sencha User jerome76's Avatar
    Join Date
    Apr 2012
    Location
    New Jersey
    Posts
    1,149
    Answers
    132
    Vote Rating
    100
      0  

    Default

    You can only use the initialize function when defining your own subclass. Check out this demo. It works there.

  4. #3
    Sencha User
    Join Date
    Jun 2012
    Posts
    52
    Answers
    4
    Vote Rating
    2
      0  

    Default

    Thanks, that worked well. Do you know if it says anywhere in the documentation that you can only overwrite initialize when defining a class?

  5. #4
    Sencha User jerome76's Avatar
    Join Date
    Apr 2012
    Location
    New Jersey
    Posts
    1,149
    Answers
    132
    Vote Rating
    100
      0  

    Default

    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •