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

RadGridView Opening Groups Programmatically

8 Answers 462 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Chaitanya
Top achievements
Rank 1
Chaitanya asked on 19 Sep 2012, 07:57 PM
Hello,

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

Sort by
0
Yoan
Telerik team
answered on 24 Sep 2012, 08:33 PM
Hello Chaitanya,

 In order to expand RadGridView's groups, you can use the ExpandGroup Method. You can access the groups through: this.radGridView.Items.Groups .

All the best,
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.

0
Raja
Top achievements
Rank 1
answered on 23 Nov 2016, 11:26 AM

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();
}
0
Yoan
Telerik team
answered on 23 Nov 2016, 02:23 PM
Hello,

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
Telerik UI for WPF is ready for Visual Studio 2017 RC! Learn more.
0
Raja
Top achievements
Rank 1
answered on 25 Nov 2016, 07:50 AM

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

0
Yoan
Telerik team
answered on 29 Nov 2016, 05:19 PM
Hi,

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
Telerik UI for WPF is ready for Visual Studio 2017 RC! Learn more.
0
Raja
Top achievements
Rank 1
answered on 01 Dec 2016, 06:19 AM

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.

0
Yoan
Telerik team
answered on 05 Dec 2016, 07:59 AM
Hi,

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
Telerik UI for WPF is ready for Visual Studio 2017 RC! Learn more.
0
Raja
Top achievements
Rank 1
answered on 07 Dec 2016, 02:00 PM

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.

Tags
GridView
Asked by
Chaitanya
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Raja
Top achievements
Rank 1
Share this question
or