This is a migrated thread and some comments may be shown as answers.

ChildRows count off by 1?

1 Answer 24 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 1
Martin asked on 13 Dec 2013, 10:17 PM
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?
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);
}

 

 

 

1 Answer, 1 is accepted

Sort by
0
George
Telerik team
answered on 18 Dec 2013, 03:28 PM
Hi Martin,

Thank you for contacting Telerik support.

Your question is already answered in the other forum thread that you have posted in: http://www.telerik.com/community/forums/winforms/gridview/radgrid-sum-expression-for-child-data.aspx. Please refer to the answer there.

We kindly ask you to use just one support channel to contact us. Posting the same questions numerous times slows down our response time because we will need to review and address two or more tickets instead of one. Moreover threads are handled according to license and time of posting, so if it is an urgent problem, we suggest you use a support ticket, which would be handled before a forum thread.

Thank you for your understanding.

Regards,
George
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
Martin
Top achievements
Rank 1
Answers by
George
Telerik team
Share this question
or