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

[Solved] Which event fire when hierarchy row expanded?

4 Answers 269 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Hazeest
Top achievements
Rank 1
Hazeest asked on 04 Nov 2009, 10:45 AM
Which event fires when hierarchy row expanded or collapsed?
How to expand or collapse the row from the code?
Thanks.

4 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 05 Nov 2009, 02:07 PM
Hello Hazeest,

The only way to understand when a row is expanded or collapsed is to attach to the grid's RowLoaded event and in the event handler create a binding to the row's IsExpanded property. This same property is used to expand and collapse the row:

using System.Windows.Controls;
using System.Windows.Data;
using Telerik.Windows.Controls;
using Telerik.Windows.Controls.GridView;
using Telerik.Windows.Data;
 
namespace TicketID_255578_HierarchyRowExpanded
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
 
            this.clubsGrid.ItemsSource = Club.GetClubs();
            this.clubsGrid.TableDefinition.ChildTableDefinitions.Add(
                new GridViewTableDefinition
                    {
                        Relation = new PropertyRelation("Players")
                    });
 
            this.clubsGrid.RowLoaded += clubsGrid_RowLoaded;
        }
 
        void clubsGrid_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e)
        {
            GridViewRow row = e.Row as GridViewRow;
            if (row != null)
            {
                Binding b = new Binding("IsExpanded")
                {
                    Source = row,
                };
 
                row.IsExpanded = true;
            }
        }
 
    }
}

By the way, we are very interested why would you need to know when hierarchy is expanded or collapsed.

Maybe you should use the RowDetails feature which offers the GridViewDataControl.RowDetailsVisibilityChanged event. Here is a link to my blog post explaining how to Display Hierarchical Data with Row Details.

I hope this helps.

Best wishes,
Ross
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Matt Meleski
Top achievements
Rank 1
answered on 12 Feb 2010, 10:26 PM
Hi,
 
In response to the Telerik's Team question, in the last post:
By the way, we are very interested why would you need to know when hierarchy is expanded or collapsed.

For me, All I want to do on Expand or Collapse, is to be able to set the Parent Row to the Selected Row..
When the Plus or Minus Sign is directly clicked on, this does NOT make this row the SelectedRow.
If there was an event for this, then it would be quite simple.

ie: There should also be an Event available for  Hierarchy plus sign, like there is for the RowsDetail plus sign:
RowDetailsVisibilityChanged event.
I have used the above event to successfully Select the correct row, but now need one for the Hierarchy Plus sign.

OR:

Is there a simple way to accomplish the above?

Thanks,

Matt
0
Vlad
Telerik team
answered on 15 Feb 2010, 07:08 AM
Hi,

You can easily achieve this suing DataLoading event:

private void RadGridView_DataLoading(object sender, Telerik.Windows.Controls.GridView.GridViewDataLoadingEventArgs e)
{
    var grid = (GridViewDataControl)sender;
    if (grid.ParentRow != null)
    {
        grid.ParentRow.GridViewDataControl.SelectedItem = grid.ParentRow.DataContext;
    }
}


Best wishes,
Vlad
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Matt Meleski
Top achievements
Rank 1
answered on 15 Feb 2010, 02:24 PM
Hi Again,

Thanks for responding.

I was trying this, but I do believe, this will work only the once.
Ie. If the row is deselected, and then is clicked on again (using the plus sign).
Then the rowloading event will not fire off again (only the first time)? Anyways I will give it try again.

Matt
Tags
GridView
Asked by
Hazeest
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Matt Meleski
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or