PDA

View Full Version : [Solved] How do I display an array of data in the Ext.Template Markup?



Elijah
23 Jun 2010, 12:44 PM
// define a template to use for the detail view
var taskTplMarkup = [
'Name: {name}<br/>',
'UserID: {id}'
]; // alertTplMarkup

var taskTpl = new Ext.Template(taskTplMarkup);
What I have is a grid panel that displays a portion of the information, and based off of the example gridpanel binding example I want to display the remainder of the information associated to the row selected in the panel below the grid.

I can get some data to display in the panel but how do I get array information to display in it? The example shows a simple structure of name value pairs and is not what I need.

For example, if I had the following data structure its not an issue to render the name or id in the grid panel or in the panel below the grid, however how would I render the pocs array?
21087

Elijah
23 Jun 2010, 1:26 PM
I found this post but cant get it to work. Anyone knowledgeable on using the for?
http://www.sencha.com/forum/showthread.php?100169-How-to-loop-through-an-array-in-a-store-using-tpl&highlight=template+array


tpl: new Ext.Template(
'<tpl for="pocs">',
'<div>{.}</div>',
'</tpl>'
)

What value is to be put into the {.}

Elijah
25 Jun 2010, 3:46 AM
Found this in the API. http://www.sencha.com/deploy/dev/docs/?class=Ext.XTemplate CLICK on the "For example usage see the constructor (http://www.sencha.com/deploy/dev/docs/output/Ext.XTemplate.html#Ext.XTemplate-XTemplate)."

Elijah
7 Jul 2010, 4:03 AM
tpl: new Ext.Template(
'Name: {name}',
'Home Phone: {homePhone}',
'<tpl for="pocs">',
'<div>id: {id}, Bank Name: {bankName}, Rating: {faaRating}, Ticker symbol: {stockId}</div>',
'</tpl>'
)

I am assuming that if I had another array within the pocs array that I would simply reference it via another <tpl...> tag set.