Display group aggregate directly on the Grouped row?

1 Answer 140 Views
GridView
Eric Moreau
Top achievements
Rank 2
Iron
Iron
Veteran
Eric Moreau asked on 25 Oct 2021, 09:35 PM

Hi

I have found this Show Summary Values for Collapsed Groups in RadGridView | Telerik UI for WinForms

It kinda work but when you have a lot of rows and 3 levels of sub-groups, you just don't see much because of all the space that is lost.

Do you have anything that would display the aggregate values directly on the grouped row?

Dess | Tech Support Engineer, Principal
Telerik team
commented on 26 Oct 2021, 12:53 PM

Hello, Eric,

The referred Knowledge Base article actually demonstrates a sample approach how to show the summary values for collapsed groups in RadGridView. A custom group cell (GridGroupContentCellElement) is created that includes the summary values in its collapsed state. Thus, the aggregate values are directly displayed on the grouped row. Could you please specify how does this solution fit your scenario? If it is not applicable, it would be greatly appreciated if you give us more details about the expected design and behavior. Once we get better understanding of the precise case, we would be able to think about a suitable solution and provide further assistance. Thank you in advance.

I am looking forward to your reply.
Eric Moreau
Top achievements
Rank 2
Iron
Iron
Veteran
commented on 26 Oct 2021, 01:25 PM

Hi Dess

Thanks for your reply.

As you can see on the attached image, lines are just doubled. And this image is still not showing the details!

What I would like is to see the sum under the columns Purchases, Redemptions, Distribution, ... to show up on the same line as the grouped row (Client ID: XX, Product: YY, Series: ZZ).

Do you have a sample for that? 

1 Answer, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 27 Oct 2021, 09:28 AM
Hello, Eric,

Note that the summary values in the collapsed state of the group row are aligned with the column headers. If the summary values are displayed in the same line as the group header, the group header text and the summary values will be overlapped.

I have updated the custom solution in the following way in order to decrease the group row's height and don't break the summary alignment with columns: 

            this.radGridView1.TableElement.GroupIndent = 100;
            this.radGridView1.TableElement.GroupHeaderHeight = 30;
        public RadForm1()
        {
            InitializeComponent();

            this.radGridView1.ViewCellFormatting += RadGridView1_ViewCellFormatting;
            this.radGridView1.GroupExpanded += RadGridView1_GroupExpanded;
        }

        private void RadGridView1_GroupExpanded(object sender, GroupExpandedEventArgs e)
        {
            e.DataGroup.GroupRow.InvalidateRow();
        }

        private void RadGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
        {
            GridGroupExpanderCellElement expanderCell = e.CellElement as GridGroupExpanderCellElement;
            if (expanderCell != null)
            {
                GridExpanderItem expanderItem = expanderCell.FindDescendant<GridExpanderItem>();
                GridViewGroupRowInfo groupRow = e.Row as GridViewGroupRowInfo;
                if (groupRow != null)
                {
                    
                    if (!groupRow.Group.IsExpanded)
                    {
                        expanderItem.Text = groupRow.HeaderText;
                    }
                    else
                    {
                        expanderItem.Text = string.Empty;
                    }
                    expanderItem.SignPadding = new Padding(0, 5, 0, 0);
                    expanderItem.TextAlignment = ContentAlignment.TopLeft;
                    expanderItem.SignStyle = SignStyles.Triangle;
                    expanderItem.SignSize = new SizeF(10, 10);
                } 
            }
        }

I believe that this approach would fit your scenario.

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Remote troubleshooting is now easier with Telerik Fiddler Jam. Get the full context to end-users' issues in just three steps! Start your trial here - https://www.telerik.com/fiddler-jam.
Eric Moreau
Top achievements
Rank 2
Iron
Iron
Veteran
commented on 27 Oct 2021, 01:02 PM

Looks very promising. Let me play with it and I'll be back.
Dess | Tech Support Engineer, Principal
Telerik team
commented on 27 Oct 2021, 01:08 PM

Eric, please have in mind that this is just a sample approach and it may not cover all possible cases. Feel free to modify and extend it in a way which suits your custom requirements best.
Eric Moreau
Top achievements
Rank 2
Iron
Iron
Veteran
commented on 29 Oct 2021, 11:13 AM

Hi

I am still playing with the code. Still looking promising. I have one issue if I remove (or set to none), the AutoSizeColumnsMode and the form is narrower than the grid content (see the attached image for an example):

 

Me.RadGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.None '.Fill

Any idea?

Eric Moreau
Top achievements
Rank 2
Iron
Iron
Veteran
commented on 29 Oct 2021, 01:22 PM

Hi

Forget my previous comment, I think I found it. I need to do more tests.

Eric Moreau
Top achievements
Rank 2
Iron
Iron
Veteran
commented on 01 Nov 2021, 12:38 PM

One more thing.

If you look at the attached image, you will see my new grid showing totals on the grouped row.

My issue is about that I have to set the indent to a value that steal most of the screen estate.

Knowing that the totals are far on the right, is there that labels shown on the grouped row (Client/Product/Series) automatically expand to a few columns to the right (maybe by checking if these columns are part of the GroupDescriptors collection). Something like the regular grouping is doing (shown on the bottom right of the capture).

Dess | Tech Support Engineer, Principal
Telerik team
commented on 02 Nov 2021, 10:40 AM

Hello, Eric,

By design, the cells clip their text considering the respective column's width. Spreading the text over the neighbouring cells is not a proper solution for this case. A better option is to wrap the text. For this purpose in the ViewCellFormatting, set the GridExpanderItem.TextWrap property to true. Then, make sure that GroupHeaderHeight property is set to a value that ensures enough height for the text.
Eric Moreau
Top achievements
Rank 2
Iron
Iron
Veteran
commented on 02 Nov 2021, 06:01 PM

Hi Dess. Thanks again for your help.

 

I think I finally figured it out as shown on the attached image.

The TextWrap is definitely not a good solution for me. Maybe the part I was really missing was the GroupHeaderHeight 

Dess | Tech Support Engineer, Principal
Telerik team
commented on 03 Nov 2021, 05:53 AM

Eric,

According to the provided screenshot, it seems that you use the very first design, the result form the initially referred KB article. Only the group header height is adjusted. Feel free to use if it fits your needs.

Tags
GridView
Asked by
Eric Moreau
Top achievements
Rank 2
Iron
Iron
Veteran
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or