Kendo ui 在网格中进行批量编辑的计算列

Kendo ui Calculated Columns with Batch Editing in Grids

我在 kendo 网格 here 中进行了 kendo 简单演示。

  1. price会根据quantity的值变化,问题是quantity变为[=16=时如何取回默认值]?

  2. 以及如何制作价格栏editable:false? (如果设置为真,价格列不能动态变化)知道吗?

full demo in dojo

save: function(e) {    
  if (e.values.hasOwnProperty("quantity")){
    var current_qty = e.values.quantity;
    var current_price = e.model.price;

    var totalPrice = current_price * current_qty;
    e.model.set('price', totalPrice);

    if(e.values.quantity == 1){
      console.log('set back to default value') ;
    }   
  }
}

这就是您使用计算字段设置列且不可编辑的方式。

columns: [
     { field: "quantity", title: "quantity", format: "{0:c}" },
     { field: "current_price", title: "current_price", format: "{0:c}" },
     { title: "totalPrice", template: "<span>#= quantity * current_price #</span>", editable: false }],

我找到了这个 article here that might help and here demo(以防有人需要)。基本上我创建了一个虚拟字段和 save 事件分配总价。