summary cell value

6 posts, 0 answers
  1. Sadly Stripy
    Sadly Stripy avatar
    1 posts
    Member since:
    Feb 2010

    Posted 25 Jun 2011 Link to this post

    Hi to all,
    I have problem to use value from cell in summary row.

    On my winform I have two radgridviews with their summary rows. How can I use that values to calculate their sum and show that result in some radlabel?

    RadLabel1.Text = sum of column "days" on RadGridView1+ sum of column "items" on RadGridView2



    Thanks,
    sadly stripy
  2. Alexander
    Admin
    Alexander avatar
    306 posts

    Posted 29 Jun 2011 Link to this post

    Hello Sadly,

    RadGridView does not provide direct API for getting the values of a summary row, but you can use any of the following approaches to achieve this:

    1. Re-evaluate the summary item and get the result value:
    GridViewSummaryRowItem summaryRowItem = this.radGridView1.SummaryRowsTop[0];
    GridViewSummaryItem summaryItem = summaryRowItem["ColumnName"][0];
    object summary = summaryItem.Evaluate(this.radGridView1.MasterTemplate);

    2. Use the GroupSummaryEvaluate event of RadGridView to get the value of a summary item:
    private object summary;
    private void radGridView1_GroupSummaryEvaluate(object sender, GroupSummaryEvaluationEventArgs e)
    {
        this.summary = e.Value;
    }

    I hope it helps you to achieve your scenario. Please note that we are still expecting an answer from you on the questions asked in your thread "element hierarchy editor problem". This will allow us to continue supporting your enquiries.

    Best regards,
    Alexander
    the Telerik team
    Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Javier Gonzalez de Aragon
    Javier Gonzalez de Aragon avatar
    35 posts
    Member since:
    Mar 2010

    Posted 26 Dec 2011 Link to this post

    Hi, I'm trying your recommendation to re-evaluate the summary item and get the result value but I'm having problems. I have summary rows on two hierarchical subgrids, not on the master template.

    My code is as follows:

    Dim CostoD As Decimal = 0
    Dim CostoI As Decimal = 0
     
    Dim summaryRowItem As GridViewSummaryRowItem = gvProduccionDetalle.Templates(0).SummaryRowsTop(0)
    Dim summaryItem As GridViewSummaryItem = summaryRowItem("CostoMP")(0)
    CostoD += summaryItem.Evaluate(gvProduccionDetalle.Templates(0))

    I receive an ArgumentOutOfRangeException when I use the Evaluate method.

    Any ideas?

    Thanks,

    Javier
  5. Svett
    Admin
    Svett avatar
    728 posts

    Posted 29 Dec 2011 Link to this post

    Hi Javier,

    Thank you for writing.

    If you want to evaluate the summary for all rows from second level in hierarchy you should use the following code snippet:
    Dim summaryRowItem As GridViewSummaryRowItem = Me.radGridView1.Templates(0).SummaryRowsTop(0)
    Dim expression As String = summaryRowItem(0).GetSummaryExpression()
    Dim value As Object = Me.radGridView1.Templates(0).DataView.Evaluate(expression, Me.radGridView1.Templates(0).Rows)

    I hope that you find this information useful. Should you have any other questions, do not hesitate to contact us.

    All the best,
    Svett
    the Telerik teamQ3’11 of RadControls for WinForms is available for download (see what's new). Get it today.
  6. Javier Gonzalez de Aragon
    Javier Gonzalez de Aragon avatar
    35 posts
    Member since:
    Mar 2010

    Posted 04 Jan 2012 Link to this post

    Thanks, that worked great. I have an other question. The previous code evaluated all of the summary items for all of the rows on the gridview. How can I get the total of each row at a time?

    Thanks again,

    Javier
  7. Svett
    Admin
    Svett avatar
    728 posts

    Posted 06 Jan 2012 Link to this post

    Hello Javier,

    If you want to evaluate the summary items of the child rows of a particular row in hierarchy, you can use the following code snippet:

    GridViewHierarchyRowInfo hierarchyRow = this.radGridView1.MasterTemplate.ChildRows[0] as GridViewHierarchyRowInfo;
    GridViewSummaryRowItem summaryRowItem = this.radGridView1.Templates[0].SummaryRowsTop[0];
    string expression = summaryRowItem[0].GetSummaryExpression();
    object value = this.radGridView1.Templates[0].DataView.Evaluate(expression, hierarchyRow.ChildRows);
    Greetings,
    Svett
    the Telerik team

    SP1
    of Q3’11 of RadControls for WinForms is available for download (see what's new).
Back to Top
UI for WinForms is Visual Studio 2017 Ready