PDA

View Full Version : Testing Xtemplates



delp
11 Feb 2014, 3:39 AM
I have a grid column which is a templatecolumn and I'm trying to modify/test it at runtime.

If I do the following in my code


tpl : new Ext.XTemplate(
'<tpl>',
'<a href="{dataLink}"><img src="' + MyApp.property.urlToImage + '" alt="{otherData}" ></img></a>',
'</tpl>'
)


This works fine. Each row in the grid has the properties dataLink and otherData. So I get my link with an image in it.
What I've been unable to do is test/modify this at runtime. I'm using Chrome and at the console I try the following



new Ext.XTemplate(
'<tpl>',
'<a href="{dataLink}"><img src="' + MyApp.property.urlToImage + '" alt="{otherData}" ></img></a>',
'</tpl>').apply([{ otherStuff: "Just some other data string in here", otherData: "pdf", dataLink: "http://urlToMyReportForLinking.pdf"}]);


It will output - "<a href=""><img src="../pdf.png" alt="" ></img></a>" - so its not picking up the data.

I'm trying to speed up my dev time and having to save, refresh for each change is a bit slow.

evant
11 Feb 2014, 3:43 AM
Something is wrong is wrong with your template. You either want:



new Ext.XTemplate(
'<tpl for=".">',
'<a href="{dataLink}"><img src="' + MyApp.property.urlToImage + '" alt="{otherData}" ></img></a>',
'</tpl>').apply([{ otherStuff: "Just some other data string in here", otherData: "pdf", dataLink: "http://urlToMyReportForLinking.pdf"}]);


OR



new Ext.XTemplate(
'<a href="{dataLink}"><img src="' + MyApp.property.urlToImage + '" alt="{otherData}" ></img></a>'
).apply({ otherStuff: "Just some other data string in here", otherData: "pdf", dataLink: "http://urlToMyReportForLinking.pdf"});

delp
11 Feb 2014, 3:46 AM
I'd no sooner finished post, then tried the following -

new Ext.XTemplate(
'<tpl for=".">',
'<a href="{dataLink}"><img src="' + MyApp.property.urlToImage + '" alt="{otherData}" ></img></a>',
'</tpl>').apply(
[{ otherStuff: "Just some other data string in here", otherData: "pdf", dataLink: "http://urlToMyReportForLinking.pdf"}]);


Notice the opening tpl tag is different now - <tpl for=".">
This works in chrome, so I can modify & test at runtime now.

delp
11 Feb 2014, 3:48 AM
Thanks evant, I'd been at it for quite a while - then after making question just got it...

The version of the Xtemplate without the for="." works in my grid column, just not while debugging.

zeedzler
2 Apr 2014, 8:06 PM
I am trying to test Sencha Apps using Rational Test Workbench. But The playback is not working properly as some of the buttons are not being pressesd during playback. Any one can help me? Thanks.

delp
4 Apr 2014, 1:35 AM
Hi Zeedzler, start a new thread with your question. That has nothing to do with the OP so its not likely to get answered in this thread.