I have a requirement where I need to open the Groups defined in a RadGridView programmatically. Basically the apporach I am looking for is to iterate over all the groups though an accessor function in RadGridView. However, there does not seem to be any accessor function to get the Groups.
It is important that I get the reference to the all the GridViewGroupRow object so that I can decide which ones to open/close. If there a way to do this from the RadGridView object and what functions / properties need to be used ? If not what are the alternatives ?
Thanks,
Chait
8 Answers, 1 is accepted
In order to expand RadGridView's groups, you can use the ExpandGroup Method. You can access the groups through: this.radGridView.Items.Groups .
Yoan
the Telerik team
Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.
I'm struggling with expanding Groups (Telerik.Windows.Control version 2016.1.217.1050)
I've tried some of recipes found on this forum, but nothing worked. What am I doing wrong?
My code snippet:
private void LayoutRoot_OnLoaded(object sender, RoutedEventArgs e) {
if (ServicesGridView?.Items?.Groups == null) {
return;
}
// method A
foreach (var it in ServicesGridView.Items) {
var groupRow = ServicesGridView.ItemContainerGenerator.ContainerFromItem( it ) as GridViewGroupRow;
if ( groupRow != null ) {
groupRow.IsExpanded = true;
}
}
// method B
foreach (var it in ServicesGridView.Items.Groups) {
IGroup g = it as IGroup;
ServicesGridView.ExpandGroup(g);
}
// may be this? not either...
ServicesGridView.InvalidateArrange();
}
Do you have groups when RadGridView is loaded? I have tested the second method and it works as expected on my side. Please note that if you want to expand all groups, then you can use RadGridView's ExpandAllGroups method.
Regards,
Yoan
Telerik by Progress
Yes, it definitely has the groups in Items.Groups which I see later rendered on the screen.
Can you specify version which you used for verifying the issue?
In my case it expands only the very first group (with method #B or with ExpandAllGroups() method).
I've tested with our latest official version. What is your version? If you are using our latest one, I will suggest to send us a sample project which demonstrates the behavior. I will debug it on my side and will assist you further.
Regards,
Yoan
Telerik by Progress
In my case - Telerik.Windows.Control version 2016.1.217.1050
I cannot simply test against the latest version due to my project's dependencies, so I would appreciate if you compare latest vs 2016.1.217.1050 and share results with me.
I've just realized that you are using Silverlight. Please note that this forum is for RadGridView for WPF. In this case, the Groups collection is null and your code doesn't execute :
private void LayoutRoot_OnLoaded(object sender, RoutedEventArgs e) {
if (ServicesGridView?.Items?.Groups == null) {
return;
.
.
.
}
May I ask you to use RadGridView's DataLoaded event instead? Please let me know how it works for you.
Regards,
Yoan
Telerik by Progress
Sorry, I've found this thread while googling for Silverlight solution, so I thought it might be useful for others.
For the topic: I've managed to find a "customization" in styles which affected Group expansion, and without this customization the group expanding works as expected with OnLoaded handler.