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

Summary rows on multiple group levels

11 Answers 395 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Allan
Top achievements
Rank 1
Allan asked on 05 Oct 2015, 06:53 PM

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?

 

 

 

11 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 07 Oct 2015, 01:25 PM
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
0
Allan
Top achievements
Rank 1
answered on 07 Oct 2015, 06:31 PM

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.

0
Hristo
Telerik team
answered on 08 Oct 2015, 03:01 PM
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
0
Allan
Top achievements
Rank 1
answered on 08 Oct 2015, 04:40 PM

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 ..

0
Accepted
Hristo
Telerik team
answered on 09 Oct 2015, 03:12 PM
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
0
jamsheer
Top achievements
Rank 1
Veteran
answered on 25 Sep 2019, 04:51 AM

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

0
Nadya | Tech Support Engineer
Telerik team
answered on 25 Sep 2019, 09:03 AM

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.
0
jamsheer
Top achievements
Rank 1
Veteran
answered on 26 Sep 2019, 06:33 AM

Hi Nadya,

     Thank you for your fast reply, 

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

 

0
Nadya | Tech Support Engineer
Telerik team
answered on 27 Sep 2019, 11:26 AM

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.
0
kevin
Top achievements
Rank 1
answered on 25 Apr 2020, 05:11 PM

Hi Nadiya

It is not working on the multiple group level.

any suggestions on how to do this?

0
Nadya | Tech Support Engineer
Telerik team
answered on 28 Apr 2020, 12:35 PM

Hello Kevin,

Note that since R1 2020 RadGridView offers ShowSubTotals properties which indicates whether summary rows will be shown for each group. On the other hand, ShowParentGroupSummaries property indicates whether the parent group summary row is visible when the grid is grouped and has multiple group levels.

I noticed that you opened another thread on the same topic. Please, see our answer there for more information.

We kindly ask you to use just one thread for a specific problem to contact us. Posting the same questions numerous times slows down our response time. Thank you for your understanding.

I hope this helps. Should you have further questions please let me know.

Regards,
Nadya
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
GridView
Asked by
Allan
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Allan
Top achievements
Rank 1
jamsheer
Top achievements
Rank 1
Veteran
Nadya | Tech Support Engineer
Telerik team
kevin
Top achievements
Rank 1
Share this question
or