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

To Get Summary Row Values in to Variable

8 Answers 631 Views
GridView
This is a migrated thread and some comments may be shown as answers.
sameer
Top achievements
Rank 1
sameer asked on 13 Jan 2011, 06:42 AM
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.

8 Answers, 1 is accepted

Sort by
0
Emanuel Varga
Top achievements
Rank 1
answered on 13 Jan 2011, 09:04 AM
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
0
Emanuel Varga
Top achievements
Rank 1
answered on 13 Jan 2011, 09:08 AM
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
0
Salman
Top achievements
Rank 1
answered on 01 Jul 2014, 12:40 PM
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*/
}
0
jamsheer
Top achievements
Rank 1
Veteran
answered on 21 Apr 2018, 07:07 AM

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.

 

0
jamsheer
Top achievements
Rank 1
Veteran
answered on 26 Apr 2018, 04:32 AM

Hi Telerik,

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

Thank you

0
Hristo
Telerik team
answered on 26 Apr 2018, 10:45 AM
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.
0
jamsheer
Top achievements
Rank 1
Veteran
answered on 30 Apr 2018, 12:04 PM

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

0
Hristo
Telerik team
answered on 30 Apr 2018, 01:50 PM
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.
Tags
GridView
Asked by
sameer
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Salman
Top achievements
Rank 1
jamsheer
Top achievements
Rank 1
Veteran
Hristo
Telerik team
Share this question
or