2014-07-22 41 views
0

我需要使用X模板顯示Ext.Dataview。輸出應基於模型屬性的一些計算。 PFB的代碼。以sencha觸摸執行計算Ext.XTemplate

Ext.define('lm.view.WaveList', { 
extend : 'Ext.DataView', 
xtype : 'waveList', 
requires : [ 


     ], 
config: { 
    itemTpl: new Ext.XTemplate('Hours Open {noOfHrsOpen/noOfHrsProjected}'), 
    store: null, 
    templateFile: null, 
    style : 'background: white', 
    pressedCls : '', 
    selectedCls : '', 
}, 

initialize: function(){ 
    this.callParent(); 


}, 


}); 

但產量不是基於計算{noOfHrsOpen/noOfHrsProjected},而它只是顯示noOfHrsOpen

任何幫助。

回答

0

您可以在Ext.XTemplate中定義可用於實現目標的函數。

var template = new Ext.XTemplate(
    'Hours Open: {[this.calculateOpenHours(values)]}', 
    { 
     calculateOpenHours: function (values) { 
       return values.noOfHrsOpen/values.noOfHrsProjected; 
      } 
     } 
    } 
); 

看看XTemplate進一步閱讀。