View Full Version : Separating XTemplate Parts

29 Jun 2010, 4:40 AM
Hello guys,

i would like to ask you if this is possible: I have a XTemplate and want to separate its parts to make it reusable for user Templates. For example:

var tpl = new Ext.XTemplate(
'<table cellpadding="3" cellspacing="3" border="0" width="100%"><tbody>',
'<tpl for=".">',

// START: Part i want to use in another template as well

'<td width="20" align="center" valign="top">',
'<td width="20" align="center" valign="top">',
'<td align="left" valign="top">',

// End

func1: function(value,record,rowIndex) {
return value
func2: function(value,record,rowIndex) {
return value;
func3: function(value, record, rowIndex) {
return value;

I tried apply etc. but it doesnt work, i pressume that it would work if would not use the tpl for="." method. and build the rows by looping the store (as seen in GroupView), but this is not what i want to do. Are there any other options?

Thanks for your answer :)

29 Jun 2010, 5:13 AM
XTemplate also takes one String as the template.

You could build that, so

myTpl = new Ext.XTemplate("<table><tr><td>" + MyApp.myComplexTpl + "</td></tr></table>");

Where you define the property myComplexTpl in your application's top level namespace.

29 Jun 2010, 6:04 AM
Thank you animal - that should do the trick :)