Grid Footer and Aggerate functions.

10 posts, 1 answers
  1. Lee
    Lee avatar
    48 posts
    Member since:
    Feb 2010

    Posted 01 Apr 2010 Link to this post


    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



  2. Answer
    Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 07 Apr 2010 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Lee
    Lee avatar
    48 posts
    Member since:
    Feb 2010

    Posted 07 Apr 2010 Link to this post

    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
  5. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 09 Apr 2010 Link to this post

    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.
  6. Lee
    Lee avatar
    48 posts
    Member since:
    Feb 2010

    Posted 10 Apr 2010 Link to this post

    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
  7. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 13 Apr 2010 Link to this post

    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.
  8. Waleed Seada
    Waleed Seada avatar
    241 posts
    Member since:
    May 2006

    Posted 21 Jun 2010 Link to this post

    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
  9. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 24 Jun 2010 Link to this post

    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
  10. Hamid N.CH
    Hamid N.CH avatar
    1 posts
    Member since:
    Jul 2012

    Posted 17 Nov 2014 Link to this post

    Hi.i want to merge all cells in summaryRow and show the count of country in middle of row.
    Best Regards.

    Hamidnch2007@gmail.com
  11. Dess
    Admin
    Dess avatar
    1601 posts

    Posted 20 Nov 2014 Link to this post

    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.

     
Back to Top
UI for WinForms is Visual Studio 2017 Ready