View Full Version : XTemplate function not getting called.

16 Sep 2012, 2:05 AM
Hi Team,

I am trying to call a XTemplate function on my panel using the panel id, but its not getting called.
I am passing an Array of records into a function and that function containing the XTemplates, i need to print the Array values in a table XTemplates function is not getting called.Although the method containing the XTemplate printing the Array record on console. Here is my code:

items : [{
flex : 6,
unstyled : true,
padding: '0 20 0 0'
statusDataLoad: function(records) {
var statusTpl = new Ext.XTemplate(
'<table align="top"><tr>',
'<tpl for=".">',
'<td ><b>{0}</b></td></tr>',

I am calling the function statusDataLoad: function(records) from controller, function is getting called.
I have written the first line of XTemplate function '<h1>Test</h1>', even it is not getting printed, Please help me out to figure out the mistake i am making.

17 Sep 2012, 2:11 AM
To render a template inside a component you should simply use the View component (http://docs.sencha.com/ext-js/4-1/#!/api/Ext.view.View). This will be much simpler than attempting to render the template directly inside the DOM of some panel.

17 Sep 2012, 3:18 AM
I would use Panel (http://docs.sencha.com/ext-js/4-1/#!/api/Ext.panel.Panel) instead

17 Sep 2012, 3:49 AM
Hi renku,
Thanks for your reply,
Can you please help me to figure out what mistake i am doing in the code. Since i am very new to ext js,
Can you please share some code to calling a Xtemplate within a function on a panel.

17 Sep 2012, 3:50 AM
Hey please help me to call a XTemplate within a function on panel.

17 Sep 2012, 3:58 AM
renku already pointed out. Don't try to render XTemplate to regular DOM element. Instead create a Ext.panel.Panel and apply XTemplate to it. Read on this (http://docs.sencha.com/ext-js/4-1/#!/api/Ext.panel.Panel-cfg-tpl) first, if you haven't already.

17 Sep 2012, 5:57 AM
Hi raghu,


Looks like you have not getting the above component, You must debug above line in your browser console.
Here is Working sample example - http://jsfiddle.net/maneeshgo/d4EcW/