PDA

View Full Version : Ext.Template: teamplte within templates?



jaimalchohan
5 Jun 2008, 3:46 AM
Hi Guys

I've got a problem that I can't seem to find the answer too. I have a Ext.Template for a RowExpander



varexpander=newExt.grid.RowExpander({
tpl:newExt.Template(
'<div style="padding:10px;">',
'<p><b>Exception</b><br />',
'&nbsp;&nbsp;&nbsp;Message: {exceptionMessage}<br />',
'&nbsp;&nbsp;&nbsp;Source: {exceptionSource}<br />',
'&nbsp;&nbsp;&nbsp;TargetSite: {exceptionSource}<br />',
'&nbsp;&nbsp;&nbsp;StackTrace: {exceptionStackTrace}<br />',
'&nbsp;&nbsp;&nbsp;Data: {exceptionDictionary}<br />',
'</p>',
'<br>',
'</div>'});


The {exceptionDictionary} is a dictionary type of object (an array of keys and values).

How would I be able to 'loop' through the array to print the items? What I'd like todo is something like



varexpander=newExt.grid.RowExpander({
tpl:newExt.Template(
'<div style="padding:10px;">',
'<p><b>Exception</b><br />',
'&nbsp;&nbsp;&nbsp;Message: {exceptionMessage}<br />',
'&nbsp;&nbsp;&nbsp;Source: {exceptionSource}<br />',
'&nbsp;&nbsp;&nbsp;TargetSite: {exceptionSource}<br />',
'&nbsp;&nbsp;&nbsp;StackTrace: {exceptionStackTrace}<br />',
'&nbsp;&nbsp;&nbsp;Data: {tpl:exceptionDictionarytemplate(exceptionDictionary)}<br />',
'</p>',
'<br>',
'</div>'}

var exceptionDictionarytemplate = newExt.Template(exceptionDictionary){
for(var i=0; i<exceptionDictionary.length;i++)
{
(
'{exceptionDictionary[i].Key}: {exceptionDictionary[i].Value}'
)
}
}}


Anything that I could do to achive this?

jaimalchohan
5 Jun 2008, 4:44 AM
Found out about XTemplate.
Problem Resolved.