Reputation: 355
I had kendo simple demo in kendo grid here.
The price
will change based on quantity
value, the problem how do I get the default value back if the quantity
change to 1
?
And How to make price column editable:false
? (if set to true, price column not able to dynamic change) Any idea?
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') ;
}
}
}
Upvotes: 0
Views: 337
Reputation: 355
I found this article here that might help and here demo (in case someone needed). Basically I created a dummy field and save
event assign the total price.
Upvotes: 1
Reputation: 3293
This is how you set your columns with a calculated field and non editable.
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 }],
Upvotes: 0