这是公式的配置:
formulas: {
//this binding with the store did not work :(
countDeactivatedVehicles: {
bind: {
bindTo: "{organizationCars}",
deep: true,
},
get: function (store) {
return store.query("isCarActive", false).getCount();
}
}
}
(目前我们想要的计数最初只显示一次,这意味着在加载时它可以正常工作)
当商店 organizationCars 中的模型更新了属性时,绑定(bind)不起作用,商店不会收到其模型已更新的警报。
理想情况下应该发生的是,当模型更新时,事件被传播到商店,以便商店知道发生了变化。这样绑定(bind)就可以工作(?)并且公式将被计算出来。
最佳答案
深度绑定(bind),不绑定(bind)那么深。
以下是您问题的答案:Fiddle
我让它在那里工作。
但是 - 就个人而言 - 我会接受 Theo 的想法,因为深度绑定(bind)是很多开销。
关于extjs - 如何将公式与 Sencha ExtJs v6 中的商店正确绑定(bind)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33892363/