2017-11-12 4 views
4

Firebaseでレコードを編集し、Math操作で2つのレコードの合計を計算するためにWebix DataTableを使用しようとしています。

これは私のDataTableの一部です:私はsum列で計算されているamountまたはpaidを編集しようとするまで

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 } 


}, 

すべてがうまく機能しています。 Math機能で編集中に競合状態に陥っているようです。

例外は次のとおりです。

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) 

は合計のみが編集後の計算作るために周りのすべての作業はありますか?または定義されていないプロパティでこの合計を計算しないようにしますか?

私はそれらの列にデフォルト値を配置しようとしましたが、全く役に立たないです。

ありがとうございます。

+0

最新のfirebaseアップデート – George

+0

+から削除したものがあります。あなたが試していることを理解するためのコードを追加する必要があります。 – George

+0

'$'はwebixの数学関数の一部です。私はそれを避けることができません –

答えて

0

@Georgeコメントに続いて、firebaseの変更により$はfirebaseキーのプレフィックスとして使用できないため、webix数学は失敗します。

回避策は、firebaseトランザクションを使用し、自分で数学を行うことです。

関連する問題