Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/377.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.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
Javascript ExtJS:如何获得两个不同JSON存储的总和';s的价值观?_Javascript_Json_Extjs_Formulas_Extjs Stores - Fatal编程技术网

Javascript ExtJS:如何获得两个不同JSON存储的总和';s的价值观?

Javascript ExtJS:如何获得两个不同JSON存储的总和';s的价值观?,javascript,json,extjs,formulas,extjs-stores,Javascript,Json,Extjs,Formulas,Extjs Stores,正如您在下文中所注意到的,我通过公式获取两个不同的存储,并获取这些JSON的总计数整数值 如何获得这两个不同的存储的总和 formulas: { firstStore: { bind: { bindTo: '{firstStatStore}', deep : true }, get: function (store) {

正如您在下文中所注意到的,我通过
公式
获取两个不同的存储,并获取这些JSON的
总计数
整数值

如何获得这两个不同的
存储的总和

formulas: {
        firstStore: {
            bind: {
                bindTo: '{firstStatStore}',
                deep : true
            },
            get: function (store) {
                var record = store.findRecord(MyApp.Names.CODE, MyApp.Names.TOTALSTAT);
                return record ? record.get(MyApp.Names.TOTALCOUNT) : "-1";
            }
        },

        secondStore: {
            bind: {
                bindTo: '{secondStatStore}',
                deep : true
            },
            get: function (store) {
                var record = store.findRecord(MyApp.Names.CODE, MyApp.Names.TOTALSTAT);
                return record ? record.get(MyApp.Names.TOTALCOUNT) : "-1";
            }
        },

       thirdStore: {
                // Here I need "sum of TOTALCOUNT" from firstStore and secondStore.
       }       
    }

您可以像绑定其他任何内容一样绑定公式:

thirdStore: function(get) {
    return get('firstStore') + get('secondStore');
}
另外,您应该更改其他公式中的返回类型,但不确定为什么要在那里返回字符串