Results 1 to 2 of 2

Thread: Using a component template in a items array

  1. #1

    Default Answered: Using a component template in a items array

    Hello, I'm having trouble getting a template to render whilst using it from within an items array, and also passing through variables. Code below:

    Code:
    Ext.define('MyTemplate', {
        extend       : 'Ext.Component',
        alias        : 'widget.mytemplate',
    
        tpl          : '<div><ul><li>{foo}</li><li>{bar}</li></ul></div>',
    
        initComponent : function() {
            this.callParent(arguments);
        }
    });
    And being used in the items array from within my view component:

    Code:
    Ext.define('MyView', {    extend   : 'Ext.form.Panel',
        alias    : 'widget.myview',
    
        initComponent: function() {
            this.items = [
                { xtype : 'mytemplate', foo : 'foo', bar : 'bar' },
                { xtype : 'textfield', fieldLabel : 'My Textfield', name : 'mytextfield' }
            ];
    
            this.callParent(arguments);
        }
    });
    I'm sure I'm doing a thousand-and-one things wrong, could anyone give me any clues, please!?

  2. Hopefully, you've figured this out by now, but you need to include your template values inside a data config. Here's a working fiddle:


  3. #2
    Ext JS Premium Member burnnat's Avatar
    Join Date
    Jun 2011
    Posts
    418
    Answers
    42

    Default

    Hopefully, you've figured this out by now, but you need to include your template values inside a data config. Here's a working fiddle:


Posting Permissions

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