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');
}
另外,您应该更改其他公式中的返回类型,但不确定为什么要在那里返回字符串