2013-04-22 27 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>'),