2013-04-22 70 views
0

我有2个字段在商店1.标题和2.活动布尔值。在sencha触摸中的ext模板存储值访问

我有以下ext.template

itemTpl : Ext.create('Ext.XTemplate', 
       '<div style = "height:5px; border-top: 0px solid #DEDEDE;">', 
        '<div style="float:left" >', 
         '<input type ="image" src="images/sort-ascending-default.png" id = "img1" name ="img1" width="30px" height="30px" />', 
        '</div>', 
        '<div class="itemTitle" id="itemTitle" style="float:left;width: 70%;height: 20px;text-align: center; color :#fffff0;">{title}</div>', 
        '<div style="float:right; vertical-align:middle;">', 
         '<input type ="image" src="images/sort-descending-default.png" id = "img2" name ="img2" width="30px" height="30px"/>', 
        '</div>', 
        '<div style="clear:both"></div>', 
       '</div>'), 

我想提出假设条件,并要检查活跃的领域,并更改标题的颜色,但我不知道如何访问存储的字段值。

+0

这里条件处理的大量实例:http://docs.sencha.com/touch/2.1.1/#!/api/Ext .XTemplate – 2013-04-22 09:57:20

回答

0

这里是你如何使用,如果条件TPL:

itemTpl : Ext.create('Ext.XTemplate', 
      '<div style = "height:5px; border-top: 0px solid #DEDEDE;">', 
       '<div style="float:left" >', 
        '<input type ="image" src="images/sort-ascending-default.png" id = "img1" name ="img1" width="30px" height="30px" />', 
       '</div>', 
       '<tpl if="active == true">', 
        '<div class="itemTitle" id="itemTitle" style="float:left;width: 70%;height: 20px;text-align: center; color :red;">{title}</div>', 
       '<tpl else>', 
        '<div class="itemTitle" id="itemTitle" style="float:left;width: 70%;height: 20px;text-align: center; color :green;">{title}</div>', 
       '</tpl>' 
       '<div style="float:right; vertical-align:middle;">', 
        '<input type ="image" src="images/sort-descending-default.png" id = "img2" name ="img2" width="30px" height="30px"/>', 
       '</div>', 
       '<div style="clear:both"></div>', 
      '</div>'),