I am using the example from here http://www.telerik.com/community/forums/winforms/gridview/radgrid-sum-expression-for-child-data.aspx to have a cell in my parent table (unbound) show the sum of the columns in a child grid. The problem I am running into is that ChildRows is off by 1. I.e. when CellValueChanged is called when I enter the amount, looks like the Row has yet to be added. Is there a better event to hook? I really want to update when the Row has been added.
Is CellValueChanged called before the ChildRows collection is updated?
Is CellValueChanged called before the ChildRows collection is updated?
private void gridExpenses_CellValueChanged(object sender, GridViewCellEventArgs e)
{
if (e.Column.OwnerTemplate != gridExpenses.MasterTemplate && e.Column.Name == "colAmount")
{
EvaluateTotal((GridViewRowInfo)e.Row.Parent);
}
}
private void EvaluateTotal(GridViewRowInfo parent)
{
if (parent.ChildRows.Count > 0)
parent.Cells["colRemaining"].Value = gridExpenses.Evaluate("Sum(colAmount)", parent.ChildRows);
}