gpt4 book ai didi

firebase - 编辑列引发 `Cannot read property ' $sum' of undefined`、Webix DataTable 和 Firebase

转载 作者:行者123 更新时间:2023-12-02 19:18:23 27 4
gpt4 key购买 nike

我正在尝试使用 Webix DataTable 来编辑 Firebase 上的记录并使用数学运算计算两条记录的总和。

这是我的数据表的一部分:

view:"datatable",
id:"clientTable",
select:true,
multiselect:true,
editable:true,
editaction:"click",
math: true,
footer:true,
columns:[
{ id:"index", header:"#", sort:"int", adjust:"data"},
{ id:"date", header:"Fecha", sort:"date", editor:"date", fillspace:true, adjust:"data", format:webix.Date.dateToStr("%d/%m/%y"), adjust:"data"},
{ id:"title", header:[ "Producto",{content:"textFilter"}], sort:"string", editor:"text", fillspace:true },
{ id:"bill", header: "Fractura", sort:"int", editor:"text", fillspace:true, text:"0"},
{ id:"amount", header: "Importe", sort:"int", editor:"text", fillspace:true, text:"0"},
{ id:"paid", header: "Pagado", sort:"int", editor:"text", fillspace:true, text:"0"},
{ id:"sum", header:"Suma", math:"[$r,amount] - [$r,paid]"}], //, cssFormat: mark_sum , footer:{content:"summColumn"}

rules:{

"title": webix.rules.isNotEmpty,


"bill": webix.rules.isNotEmpty,
"amount": webix.rules.isNotEmpty,
"paid": webix.rules.isNotEmpty,
"sum": webix.rules.isNotEmpty,


"bill": webix.rules.isNumber,
"amount": webix.rules.isNumber,
"paid": webix.rules.isNumber,
"sum": webix.rules.isNumber,

"bill": function(value){ return value > 0 },
"amount": function(value){ return value > 0 },
"paid": function(value){ return value >= 0 },
"sum": function(value){ return value >= 0 }


},

一切正常,直到我尝试编辑在sum列中计算的金额付费。我在使用 Math 函数进行编辑时似乎遇到了竞争条件。

异常(exception)情况是:

Uncaught TypeError: Cannot read property '$sum' of undefined
at h.jn (webix.js:1103)
at h.jn (webix.js:1104)
at h.gn (webix.js:1102)
at webix.DataStore.<anonymous> (webix.js:13)
at webix.DataStore.callEvent (webix.js:23)
at webix.DataStore.updateItem (webix.js:524)
at h.updateItem (webix.js:545)
at h.ri (webix.js:790)
at h.<anonymous> (webix.js:788)
at h.si (webix.js:1115)

是否有任何解决方法可以使总和仅在编辑后计算?或者避免在未定义的属性上计算此总和?

我尝试为这些列添加默认值,但根本没有帮助。

谢谢。

最佳答案

根据 @George 评论,由于 firebase 更改,$ 无法用作 firebase 键的前缀,因此 webix 数学运算失败。

解决方法是使用 Firebase 事务并自行计算。

关于firebase - 编辑列引发 `Cannot read property ' $sum' of undefined`、Webix DataTable 和 Firebase,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47246377/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com