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?
1 Answer, 1 is accepted
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
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?
Hi
Forget my previous comment, I think I found it. I need to do more tests.
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).
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.
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
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.
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.
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?