剑道UI:如何求和两个字段并在第三个字段中显示


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

我目前正在使用剑道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"answers"iva"之间进行数学运算,并实时将答案显示在"valor"字段上。

有什么建议吗?

您需要为您的网格实现保存功能。当您更改单元格值并按enter键时,它将被激发。您的问题不包括整个源代码,但实现应该是这样的:

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

希望这能有所帮助。