Nixoderm
Nixoderm

Reputation: 355

Kendo ui Calculated Columns with Batch Editing in Grids

I had kendo simple demo in kendo grid here.

  1. The price will change based on quantity value, the problem how do I get the default value back if the quantity change to 1?

  2. And How to make price column editable:false? (if set to true, price column not able to dynamic change) Any idea?

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') ;
    }   
  }
}

Upvotes: 0

Views: 337

Answers (2)

Nixoderm
Nixoderm

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

CMartins
CMartins

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

Related Questions