PDA

View Full Version : tpl if inside tpl for



jedihua
25 Feb 2011, 10:38 AM
Hi, What if I need to check values inside a tpl for loop

for example:
<tpl for="TEST">
<tpl if="TEST.LOW_VALUE == 0"> No Low! </tpl>
<tpl if="TEST.LOW_VALUE == 1"> Low! </tpl>
</tpl>

TEST is an array with LOW_VALUE.

StuartAshworth
25 Feb 2011, 1:10 PM
Inside a FOR loop the current item in the array is used when referencing other fields within it, so if you take the "TEST." off it will look in the current TEST object for the LOW_VALUE value.




var data = {TEST: [{LOW_VALUE: 0}, {LOW_VALUE: 1}]};

var tpl = new Ext.XTemplate('<tpl for="TEST">',
'<tpl if="LOW_VALUE == 0"> No Low! </tpl>',
'<tpl if="LOW_VALUE == 1"> Low! </tpl>',
'</tpl>');

tpl.apply(data);



Hope that makes sense...