To Get Summary Row Values in to Variable

9 posts, 0 answers
  1. sameer
    sameer avatar
    1 posts
    Member since:
    Jan 2011

    Posted 13 Jan 2011 Link to this post

    I have a Summary Row in the bottom of the Grid, I want to get the value of summaryrowitem in to the variable. how i can do this ?
    Secondly, how we can do the conditional formatting of the summary row.
  2. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 13 Jan 2011 Link to this post

    Hello Sameer,

    I have solved a problem like this in this thread, i have provided a few options there please take a look at those and if you need more assistance i will be happy to help. If it were up to me i would suggest my second reply (that is not marked) because if offers a clean way to get the values of the SummaryItems without the need to store them in a variable, dictionary or other things.
    Or if you don't need such complex things, you can just handle the GroupSummaryEvaluate event and take the value there and store it in a variable.

    Second question coming up

    Best Regards,
    Emanuel Varga
    Telerik WinForms MVP
  3. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 13 Jan 2011 Link to this post

    Hello again, as promised,

    Just use ViewRowFormatting event, like so:
    void radGridView1_ViewRowFormatting(object sender, RowFormattingEventArgs e)
    {
        if (e.RowElement is GridSummaryRowElement)
        {
            e.RowElement.SetValue(LightVisualElement.BackColorProperty, Color.Red);
            e.RowElement.DrawFill = true;
        }
        else
        {
            e.RowElement.ResetValue(LightVisualElement.BackColorProperty);
            e.RowElement.ResetValue(LightVisualElement.DrawFillProperty);
        }
    }

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga
    Telerik WinForms MVP
  4. Salman
    Salman avatar
    3 posts
    Member since:
    Jul 2014

    Posted 01 Jul 2014 in reply to Emanuel Varga Link to this post

    Yes You can have summary row Items and their values too.....
    After Inserting a grid view and making a row summary item
    goto the properties of GridView you inserted and Select
    GroupSummaryEvaluate()
    event from Properties Event window Now goto the code section of windows form and there u will see
    int count=0;
    Private Void RadGridView1_GroupSummaryEvaluate(object Sender, GroupSummaryEvaluateArg e){
    //Here you will write the following code in the code section
    try
          this.cursor=cursors.waitcursor;
          object value=e.value;
      if(count==0){
            messagebox.show(value.toString());
          count++;
       }
      else{
            messagebox.show(value.toString());
        count=0;
       }
    }
    catch(exception ex){
                       ;
    }
    finally{
          this.cursor=cursors.default;
    }
    /*It will give us value one by as if we have group summary items like count the items in the list and other grand total of the items in the list, it will show them to us one by one means it will show Item count of list first and then will show us total of the items It works*/
    }
  5. jamsheer
    jamsheer avatar
    56 posts
    Member since:
    Feb 2017

    Posted 21 Apr 2018 Link to this post

    Hi,

    I have a Grouped gridview with summery rows, Where I' am trying to insert all gridview rows to datatable including summery rows order by as a gridview,

    But I can't get the summery rows of grid, How could I insert all rows to datatable.

    I attached my gridview pic below. Where all summery rows (A, B and C) must I need to insert

    Thank you.

     

  6. jamsheer
    jamsheer avatar
    56 posts
    Member since:
    Feb 2017

    Posted 25 Apr 2018 Link to this post

    Hi Telerik,

       Can you give any suggestion for my question. Its very urgent.

    Thank you

  7. Hristo
    Admin
    Hristo avatar
    1438 posts

    Posted 26 Apr 2018 Link to this post

    Hello Jamsheer,

    You can access the added summary row items by accessing the SummaryRowsTop and SummaryRowsBottom collections. The items in these collections are logical GridViewSummaryRowItems which have defined property names and aggregates. Your screenshot indicates that you need to access each of the groups and the actual GridViewSummaryRowInfo objects and their values. This can be accomplished as per the code snippet below: 
    foreach (DataGroup group in this.radGridView1.Groups)
    {
        foreach (GridViewSummaryRowInfo summaryRow in group.GroupRow.TopSummaryRows)
        {
            foreach (GridViewSummaryItem summaryItem in summaryRow.SummaryRowItem)
            {
                string summary = summaryRow.GetSummary(this.radGridView1.Columns[summaryItem.Name]);   
            }
        }
    }

    Then you can call their GetSummary method and receive the aggregated value. Once you have the values and the count of the actual summary rows you can update your data table.

    Regards,
    Hristo
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  8. jamsheer
    jamsheer avatar
    56 posts
    Member since:
    Feb 2017

    Posted 30 Apr 2018 Link to this post

    Hi Telerik,
       Thanks for your replay, But where I want to get the grid values into Datatable , not to any variable.

    Order by 

    1. Gridview Grouped column name
    2. Gridview rows
    3. Gridview summery row
    4. Total of summery rows at last row

    In the below pic I marked the row order .

    Thank you

  9. Hristo
    Admin
    Hristo avatar
    1438 posts

    Posted 30 Apr 2018 Link to this post

    Hello Jamsheer,

    The summary rows are a result of certain calculations according to the provided aggregate function. Since you need to add the summary rows to your data table, you will need to create a new record for each summary row. You can use the code snippet I sent earlier to get the aggregated values.

    I hope this information is useful.

    Regards,
    Hristo
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top