Summary rows on multiple group levels

10 posts, 1 answers
  1. Allan
    Allan avatar
    3 posts
    Member since:
    Oct 2015

    Posted 05 Oct 2015 Link to this post

    I am working on rewriting our grid reporting system using the Telerik GridView. I have run into one thing I have no been able to do. When I group a report, I need to show a summary row for all group levels. I have attached an example of what I need to do. In it I am grouping on two columns: View & User Id. I show a summary row for each user (pink) and then another summary row for each view (blue). 

    I have tried to do the same thing with the gridview but i have  only been able to show a summary row for the lowest level group. 

     Does any one have an suggestions on how to do this?

     

     

     

  2. Hristo
    Admin
    Hristo avatar
    1517 posts

    Posted 07 Oct 2015 Link to this post

    Hi Alan,

    Thank you for writing.

    I believe that the following KB resource implementing custom summary cells could help you in achieving your task: http://www.telerik.com/support/kb/winforms/gridview/details/gridview-with-visible-summary-cells-in-a-collapsed-group.

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo Merdjanov
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  3. Allan
    Allan avatar
    3 posts
    Member since:
    Oct 2015

    Posted 07 Oct 2015 in reply to Hristo Link to this post

    Yes, that is exactly what I was looking for. I added the sample code to my program and it worked.

    I just have one question. I can see that the group summary is actually being placed in the summary header. This is a good trick. But this means that the summary ends up on top of the group. I actually want it on the bottom. Is it possible to create a new row instead of using the group header and have that row at the end of the group. This would match what I am currently doing.

  4. Hristo
    Admin
    Hristo avatar
    1517 posts

    Posted 08 Oct 2015 Link to this post

    Hello Allan,

    Thank you for writing.

    In order to achieve this task you can add the summary row to the bottom of the grid when it is grouped. In order to make this work, you would also need to change the custom GridGroupContentCellElement  so that it performs the required calculations according to a row in the bottom.

    I am sending you attached a modified version of the project as well as a gif file showing the result on my end.

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo Merdjanov
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  5. Allan
    Allan avatar
    3 posts
    Member since:
    Oct 2015

    Posted 08 Oct 2015 in reply to Hristo Link to this post

    That is getting closer. But I also need to move the summary row of the level 1 group to the bottom. This is the tricky part. Is it possible?

     I have attached a diagram to show what I mean.

     

    Thanks ..

  6. Answer
    Hristo
    Admin
    Hristo avatar
    1517 posts

    Posted 09 Oct 2015 Link to this post

    Hello Allan,

    Thank you for writing back.

    With the current implementation, that would not be possible. As you have noticed, we are using the GridGroupContentCellElement to host the custom cells providing the information for the summaries. The location of this cell is more or less static while the inner groups are created dynamically according to the rows in the inner view templates. 

    In the example, I last sent you, these items are moved on the bottom when the group is expanded. If it is collapsed and the items are moved to the bottom they will be easily mistaken with the summaries of the other groups.

    I hope this information is useful. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo Merdjanov
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  7. jamsheer
    jamsheer avatar
    64 posts
    Member since:
    Feb 2017

    Posted 24 Sep 2019 Link to this post

    Hi,

         Where I have Radgrid with three column (string and decimal columns) that is the attached Pic-A. I need to sum the decimal columns and show only that column If I group the  string column, That is the result should I come only show the summery rows and grouped rows, please specify I attached pic-B

    Regarding

    Jamsheer

  8. Nadya
    Admin
    Nadya avatar
    191 posts

    Posted 25 Sep 2019 Link to this post

    Hello Jamsheer,

    The provided information and pictures are greatly appreciated. To achieve this behavior you should iterate through the data rows which are represented as GridViewRowInfo in the ChildRows collection of the group row, and set the IsVisible property to false. Please refer to the following code snippet which demonstrates this:

    this.radGridView1.GroupByChanged += RadGridView1_GroupByChanged;
    private void RadGridView1_GroupByChanged(object sender, GridViewCollectionChangedEventArgs e)
    {
        if (e.Action== Telerik.WinControls.Data.NotifyCollectionChangedAction.Add && this.radGridView1.GroupDescriptors.Contains("Item Name"))
        {
            UpdateRowVisibility(false);
    
        }
        else if (e.Action == Telerik.WinControls.Data.NotifyCollectionChangedAction.Remove && ! this.radGridView1.GroupDescriptors.Contains("Item Name"))
        {
            UpdateRowVisibility(true);
        }
    
    }
    
    public void UpdateRowVisibility(bool visible)
    {
        foreach (GridViewRowInfo row in this.radGridView1.ChildRows)
        {
            row.IsVisible = true;
            foreach (GridViewRowInfo childRow in row.ChildRows)
            {
                childRow.IsVisible = visible;
            }
        }
    }
    

    Please, note that the RadGridView has ShowTotals property which indicates whether total summary rows are visible in a grouping. Feel free to use it if it is suitable for you:

    this.radGridView1.MasterTemplate.ShowTotals = true;

    I hope this helps. Should you have any other questions, I will be glad to help.

    Regards,
    Nadya
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  9. jamsheer
    jamsheer avatar
    64 posts
    Member since:
    Feb 2017

    Posted 26 Sep 2019 Link to this post

    Hi Nadya,

         Thank you for your fast reply, 

    Is there any option for getting Sub Total like Excel Sub Total

     

  10. Nadya
    Admin
    Nadya avatar
    191 posts

    Posted 27 Sep 2019 Link to this post

    Hello Jamsheer,

    You can use the ShowGroupedColumns property to show the columns by which the data is grouped and show the cell text as shown in the following code snippet:

     this.radGridView1.MasterTemplate.ShowGroupedColumns = true;
     this.radGridView1.ViewCellFormatting += RadGridView1_ViewCellFormatting;
    private void RadGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
    {
        GridSummaryCellElement cell = e.CellElement as GridSummaryCellElement;
    
        if (cell != null && e.Column.Name == "Item Name")
        {
            if (e.Row.Group != null)
            {
                cell.Text = "SubTotal";
            }
            else 
            {
                cell.Text = "Total";
            }
        }
    }
    

    This is the achieved result:

    Please refer to the following help article as well, which demonstrates how to format the header text of the group rows: https://docs.telerik.com/devtools/winforms/controls/gridview/grouping/formatting-group-header-row

    However, if this is not the exact goal that you are trying to achieve, it would be greatly appreciated if you can provide more information about your custom requirement. Thus, we would be able to think about a suitable solution and assist you further. Thank you in advance.

    I hope this information helps. If you need any further assistance please don't hesitate to contact me

    Regards,
    Nadya
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top