2013-05-21 117 views
0

我正在获取月,目标,Target1值来自商店中可用的webservice。我想计算总值并将总字段值插入同一商店。如何在extjs中插入特定商店字段的记录

我正在做这个计算,但我不知道如何将总值插入总字段。任何人都可以告诉我如何做到这一点?

chartstore.each(function (rec) {     
    total=parseFloat(rec.get('target'))+parseFloat(rec.get('target1')); 
}); 

Month Target Target1 Total 

Jan 25  25  50 
Mon 50  50  100 

回答

2

您应该使用转换函数模型中的总场像下面

 { 
     name : 'total', 
     convert : function(value, record) { 
         var totalValue = record.get('Target') + record.get('Target1'); 
         return totalValue; 
     } 
     type: 'number' 
    }, 
0

您可以在您的商店,其将被隐藏的模型添加场。

chartstore.each(function (rec) { 

        total=parseFloat(rec.get('target'))+parseFloat(rec.get('target1')); 
        /* Here set the total field,like store.getAt(index).total with the above total value*/ 

}); 

我还没有测试过这个,但我认为它应该可以工作。