Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在extjs中插入特定存储字段的记录_Extjs_Extjs4.1_Sencha Architect_Extjs4.2 - Fatal编程技术网

如何在extjs中插入特定存储字段的记录

如何在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

我从商店中提供的webservice中获得月、目标、目标1值。我想计算总值,并在同一个存储中插入字段总值

我这样做是为了计算,但我不知道如何将总值插入“总计”字段。有人能告诉我怎么做吗

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'
    },