RadGridView Opening Groups Programmatically

9 posts, 0 answers
  1. Chaitanya
    Chaitanya avatar
    3 posts
    Member since:
    Aug 2012

    Posted 19 Sep 2012 Link to this post

    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

  2. Yoan
    Admin
    Yoan avatar
    1214 posts

    Posted 24 Sep 2012 Link to this post

    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.

  3. Raja
    Raja avatar
    4 posts
    Member since:
    Nov 2016

    Posted 23 Nov 2016 in reply to Yoan Link to this post

    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();
    }
  4. Yoan
    Admin
    Yoan avatar
    1214 posts

    Posted 23 Nov 2016 Link to this post

    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.
  5. Raja
    Raja avatar
    4 posts
    Member since:
    Nov 2016

    Posted 25 Nov 2016 in reply to Yoan Link to this post

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

  6. Yoan
    Admin
    Yoan avatar
    1214 posts

    Posted 29 Nov 2016 Link to this post

    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.
  7. Raja
    Raja avatar
    4 posts
    Member since:
    Nov 2016

    Posted 01 Dec 2016 in reply to Yoan Link to this post

    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.

  8. Yoan
    Admin
    Yoan avatar
    1214 posts

    Posted 05 Dec 2016 Link to this post

    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.
  9. Raja
    Raja avatar
    4 posts
    Member since:
    Nov 2016

    Posted 07 Dec 2016 in reply to Yoan Link to this post

    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.

Back to Top