Editing the raise column `Cannot read the $ sum 'property from undefined`, Webix DataTable and Firebase

I am trying to use Webix DataTable to edit records in Firebase and calculate the sum of two records using a Math operation.

This is part of my datatable:

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 }


},

Everything works well until I try to edit amountor paid, which are calculated in a column sum. It seems that I have a race condition when editing using a function Math.

The exception is:

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)

Is there any work to calculate the amount only after editing? or not count this amount on undefined properties?

I tried to place default values ​​for these columns, but this does not help at all.

Thank.

+4
source
1

@George, - firebase $ firebase, webix.

- firebase .

0

Source: https://habr.com/ru/post/1689150/


All Articles