Hi,
I have a sub-grid where only a few columns are editable (InCell/batch mode).
I'm trying to display and update aggregate values for a calculated field/column.
I have tried 2 approaches, but got stuck with both:
1) Using the ViewModel
I have added calculated field to my ViewModel class
public int Quantity { get; set; }
public decimal UnitCost { get; set; }
public decimal TotalAmount
{
get { return (decimal) Quantity * UnitCost; }
}
This does allow me to define an aggregate value for TotalAmount in the DataSource section, and that displays correctly initially.
But if I modify Quantity or UnitCost (both editable columns in the grid, using InCell editing), the value of TotalCost doesn't get updated accordingly.
Can I force a refresh of the contents of the row and the aggregate values (e.g. in onSave() function?) *without* saving the edits, and if so: how?
2) Using a calculated column
Following the instructions of your colleague in this post:
https://www.telerik.com/forums/asp-net-kendo-ui-grid-calculated-column
... I defined a Template-type column with calculated values.
function calculateField(data) {
var totalCost = data.Quantity * data.UnitCost;
return totalCost;
}
But that value doesn't get updated either when I change the values of Quantity or UnitCost.
Furthermore, I don't know if it's possible to define/display aggregate values for a column of type Template?
Appreciate your help,
Erik