View Full Version : tpl if inside tpl for

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>

TEST is an array with LOW_VALUE.

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>',


Hope that makes sense...