1

Instead of having a control where we concatenate a huge HTML string, I'd like to separate the XTemplate object into its own file. The problem is that I don't know how to set the template text in this class. Normally, you'd create a new XTemplate object in-line and pass the template text as the first parameter.

Is this possible? What property should I be setting?

/**
 * Custom XTemplate
 */
Ext.define('MyApp.view.MySuperDuperXTemplate', {
    extend: 'Ext.XTemplate',
    xtype: 'mySuperDuperXTemplate',

    html: 'Does the template text go here?',
    text: 'That didn\'t work, let me try this...',
    tpl: 'How about this?  No?...'
});
JackAce
  • 1,407
  • 15
  • 32

1 Answers1

2

XTemplate gets the HTML when you pass it in the constructor, so you would need to override that to create it:

Ext.define('Test', {
    extend: 'Ext.XTemplate',

    html: 'testing',

    constructor: function() {
        return this.callParent([this.html]);
    }
});

// Then use it
new Test();
rdougan
  • 7,217
  • 2
  • 34
  • 63
  • Thanks! Quick question: It doesn't seem to matter what you call the property, correct? You can call it html, text, or mySuperDuperProperty. It seems to just be a temporary property used to pass to the constructor, correct? – JackAce Nov 15 '12 at 19:01