簡體   English   中英

Kendo UI:如何對兩個字段求和並在第三個字段中顯示

[英]Kendo UI: How to SUM two fields and show in a 3rd one

我目前正在使用kendo ui,但遇到了一些小問題,得到了網格

schema: 
                                 {
                                     data: "data",
                                     total: function(response) 
                                     {
                                         return response.data.length;
                                     },
                                     model: 
                                     {
                                             id: "id",
                                             fields: 
                                             {
                                                 clasificacion      :{editable: false},
                                                 tipo_rubros        :{editable: false },
                                                 rubro              :{editable: false },
                                                 proveedor_rubro    :{editable:false },
                                                 valor              :{editable: false ,type:"number"},
                                                 num_factura        :{editable: true },
                                                 neto               :{editable: true ,type:"number"},
                                                 iva                :{editable: true ,type:"number"},
                                                 observacion        :{editable: true },
                                                 fecha_factura      :{editable: true  },
                                             }
                                     }                      
                                 },
                                  group: {

                                        field: "tipo_rubros", aggregates: [
                                       { field: "valor", aggregate: "sum"}
                                        ]
                                  },
                                 aggregate: [ { field: "valor", aggregate: "sum" },
                                 ]
                         },

我想在“ neto”和“ iva”之間進行數學運算,並且答案實時出現在“ valor”字段中。

有什么建議嗎?

您需要為網格實現保存功能。 更改單元格值並按Enter時將觸發它。 您的問題不包括整個源代碼,但是實現應如下所示:

save: function (e) {
   yourDataSource.valor = e.model.neto + e.model.iva;
   yourGrid.data('kendoGrid').dataSource.read();
   yourGrid.data('kendoGrid').refresh();
}

希望這會有所幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM