ChildRows count off by 1?

2 posts, 0 answers
  1. Martin
    Martin avatar
    3 posts
    Member since:
    Dec 2013

    Posted 13 Dec 2013 Link to this post

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

     

     

     

  2. George
    Admin
    George avatar
    500 posts

    Posted 18 Dec 2013 Link to this post

    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 >>
Back to Top