如何在extjs中插入特定存储字段的记录
我从商店中提供的webservice中获得月、目标、目标1值。我想计算总值,并在同一个存储中插入字段总值 我这样做是为了计算,但我不知道如何将总值插入“总计”字段。有人能告诉我怎么做吗如何在extjs中插入特定存储字段的记录,extjs,extjs4.1,sencha-architect,extjs4.2,Extjs,Extjs4.1,Sencha Architect,Extjs4.2,我从商店中提供的webservice中获得月、目标、目标1值。我想计算总值,并在同一个存储中插入字段总值 我这样做是为了计算,但我不知道如何将总值插入“总计”字段。有人能告诉我怎么做吗 chartstore.each(function (rec) { total=parseFloat(rec.get('target'))+parseFloat(rec.get('target1')); }); 您可以在商店模型中添加一个将被隐藏的总计字段 char
chartstore.each(function (rec) {
total=parseFloat(rec.get('target'))+parseFloat(rec.get('target1'));
});
您可以在商店模型中添加一个将被隐藏的总计字段
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*/
});
我还没有对此进行测试。但我认为它应该可以工作。您应该在模型中为total字段使用convert函数,如下所示
{
name : 'total',
convert : function( value, record ) {
var totalValue = record.get('Target') + record.get('Target1');
return totalValue;
}
type: 'number'
},
{
name : 'total',
convert : function( value, record ) {
var totalValue = record.get('Target') + record.get('Target1');
return totalValue;
}
type: 'number'
},