我在剑道网格here中有剑道简单演示。
price
会根据quantity
的值而变化,这是一个问题,如果quantity
更改为1
,如何恢复默认值?
以及如何制作价格列editable:false
? (如果设置为true,则价格列将无法动态更改)。
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') ;
}
}
}
答案 0 :(得分:1)
答案 1 :(得分:0)
这是设置列的方式,该列具有计算所得的字段且不可编辑。
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 }],