2014-10-13 38 views
0

我正在使用sencha touch來開發移動應用程序。在列表中,我使用Css將大於0(到綠色)和小於0(到紅色)的值更改爲顏色。對於小於1000的顏色變化,但比1000顏色沒有變化較大值值..請幫助如果條件在sencha touch中不起作用

我的代碼

<div class="amt_txt"> 
    <tpl if="Amount &gt;= 0"> 
     <span class='drill'> 
      <strong> 
       <span class='dollartxt'> 
        $ 
       </span> 
       {Amount} 
      </strong> 
     </span> 
    <tpl elseif="Amount &lt;=0"> 
     <span class="YldDataColor3"> 
      <span class='dollartxt'> 
       $ 
      </span> 
      {Amount} 
     </span> 
    </tpl> 
</div> 

回答

0

我會用這樣的功能:

new Ext.XTemplate(
    '<div class="amt_txt">' + 
     '<span class="classForBold{[this.classChooser(values)]}">' + // <<--- here is the call 
      '<span class='dollartxt'>' + 
       '$' + 
      '</span>' + 
      '{Amount}' + 
     '</span>' + 
    '</div>', 
    classChooser: function(values) { // <<--- here is the function 
     var amount = value.Amount, returnValue; 

     switch (amount) { 
      case < 1000: 
       returnValue = ' drill'; // important leading blank 
       break; 
      case < 0: 
       returnValue = ' YldDataColor3'; 
       break; 
      default: 
       returnValue = ''; 
     } 
     return returnValue; 
    } 
)