我在商店中有2个字段1.标题和2.有效布尔值。
我有以下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>'),
我想在其中添加if条件并想要检查活动字段并更改标题的颜色,但我不知道如何访问商店字段值。
答案 0 :(得分:0)
以下是如何在tpl中使用if条件:
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>'),