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

Grid Footer and Aggerate functions.

9 Answers 443 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Lee
Top achievements
Rank 1
Lee asked on 01 Apr 2010, 09:28 AM

Question#1.   I am displaying Products table in grid control.  Its a simple list of products. at the end of grid i want to display Count of products.

Question#2.   when i use grid's group feature, then it should display Count of products for each group and also display Total count at the end of grid.

Is above possible. Any code sample or ideas.

Regards



9 Answers, 1 is accepted

Sort by
0
Accepted
Julian Benkov
Telerik team
answered on 07 Apr 2010, 09:19 AM
Hi Lee,

Here are the answers to your questions:

1) To add an aggregate/count in the footer use this code:

GridViewSummaryItem summaryTotal = new GridViewSummaryItem("Country", " Total: {0} ", GridAggregateFunction.Count);
    this.radGridView1.MasterGridViewTemplate.SummaryRowsBottom.Add(
        new GridViewSummaryRowItem(new GridViewSummaryItem[] { summaryTotal }));
  
2) For each group use this code:

GridViewSummaryItem summary = new GridViewSummaryItem("Country", " Count: {0} ", GridAggregateFunction.Count);
    this.radGridView1.MasterGridViewTemplate.SummaryRowGroupHeaders.Add(
        new GridViewSummaryRowItem(new GridViewSummaryItem[]{summary}));

Sincerely yours,

Julian Benkov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Lee
Top achievements
Rank 1
answered on 07 Apr 2010, 12:51 PM
Hi Julian,

It worked.  Thanks.

Now can  I give some style to this footer summary row. like "Red" background and a different font and size.?

Regards
0
Julian Benkov
Telerik team
answered on 09 Apr 2010, 01:50 PM
Hi Lee,

You can use ViewRowFormatting or ViewCellFormatting to change the appearance of a row or a cell:

void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
{
    if (e.CellElement.RowInfo is GridViewSummaryRowInfo && e.CellElement.ColumnIndex == 8)
    {
        e.CellElement.DrawFill = true;
        e.CellElement.GradientStyle = GradientStyles.Solid;
        e.CellElement.BackColor = Color.Red;
        e.CellElement.Font = new Font(e.CellElement.Font, FontStyle.Bold);
    }
}

Sincerely yours,

Julian Benkov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Lee
Top achievements
Rank 1
answered on 10 Apr 2010, 10:09 AM
Hi Julian Benkov, 

Thanks.     Is it that this can only be done via coding?  or we can set formatting of Aggerate Row(s) at design time too?

Regards
0
Julian Benkov
Telerik team
answered on 13 Apr 2010, 01:03 PM
Hello Lee,

In the current edition of RadGridView the only possible solution is to change the rendering of the summary rows. In the next edition of the control we plan to extend the API and improve the formatting, as well as the summary items and rows layouts. More information of RadGridView vNEXT you can find here.
 

Regards,
Julian Benkov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Waleed Seada
Top achievements
Rank 2
answered on 21 Jun 2010, 09:00 AM
Hello there,

I used the posted code, but it doesn't show anything for the summary for the whole rows, when I group by any of the columns I found the count = 0 added to each group but not the right count, what do i missing here ...

Regards
Waleed
0
Julian Benkov
Telerik team
answered on 24 Jun 2010, 09:34 AM
Hello Waleed Seada,

Please open a new support ticket and send us a sample project or some code snippets with your scenario which will help us to reproduce the issue locally. This will allow us to understand your case and provide you with further assistance.

Regards,
Julian Benkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Hamid N.CH
Top achievements
Rank 1
answered on 17 Nov 2014, 06:10 PM
Hi.i want to merge all cells in summaryRow and show the count of country in middle of row.
Best Regards.

Hamidnch2007@gmail.com
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 20 Nov 2014, 01:48 PM
Hello Hamid,

Thank you for writing.

In order to position the summary item centered, instead of below/above the corresponding column, you can use the ViewCellFormatting event and customize the GridSummaryCellElement.PositionOffset property. Thus, you can place the cell wherever is suitable for you.

As to the question related to merging cells, you can have a look at the RadGridView Merge Cells KB article.

I hope this information helps. Should you have further questions, I would be glad to help.

Regards,
Desislava
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
GridView
Asked by
Lee
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Lee
Top achievements
Rank 1
Waleed Seada
Top achievements
Rank 2
Hamid N.CH
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or