Extjs Xtemplate

extjs

http://vimeo.com/17905336

Member functions
Subtemplates
Recursive templates
List layout

var tpl = new Ext.XTemplate('<div>Hello {entity}</div>');
tpl.append(Ext.getBody(), {entity: 'World'});

How to use member function?

var mainTpl = new Ext.XTemplate(
  '<tpl for=".">',
    '<div class="container">',
      '{[this.renderItem(values)]}',
    '</div>',
  '</tpl>',
  {
    renderItem: function(values) {
      if (values instanceof DateRange) {
        return dateRangeTpl.apply(values);
      }
      else {
        return notNullTpl.apply(values);
      }
    }
  }
);
new Ext.XTemplate(
    '<tpl for="name">',
    '{[this.renderItem(values)]}',
    '</tpl>',
    {
        renderItem: function(values) {
            if (values == "A") {
                return "Generic Questions";
            } else {
                return values;
            }
        }
    }
)

What are the parameters to new Ext.XTemplate()?

It takes a list of strings to be concatenated together to form the final xtemplate. The last parameter can be an object specifying member functions. See the documentation for more detail.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License