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

[Solved] Hierarchy and SelectionChanged

3 Answers 117 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.
Tomasz Wisniewski
Top achievements
Rank 1
Tomasz Wisniewski asked on 07 Oct 2010, 10:09 AM
Hi,

I'm using a hierarchy in my datagrid. How can make the SelectionChanged event fire when I click the "+" instead of the row itself?

3 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 07 Oct 2010, 10:46 AM
Hello Tomasz Wisniewski,

You may add a handler for the GridViewToggleButton that listens for the MouseLeftButtonDown event. Afterwards, all you need to do is to find the parent of that button - a GridViewRow in this case and set its IsSelected Property to "True".
For instance:

public MainPage()
{
    InitializeComponent();
          
  this.clubsGrid.AddHandler(GridViewToggleButton.MouseLeftButtonDownEvent, new MouseButtonEventHandler(OnMouseDown), true);
}
 
private void OnMouseDown(object sender, MouseButtonEventArgs e)
{      
    RadGridView grid = sender as RadGridView;
    var buttons = grid.ChildrenOfType<GridViewToggleButton>();
    foreach (GridViewToggleButton button in buttons)
    {
        if (button.IsPressed)
        {
            GridViewRow parentRow = button.ParentOfType<GridViewRow>();
            if (parentRow != null)
            {
                parentRow.IsSelected = true;
            }
        }
    }
}
 

Greetings,
Maya
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
Tomasz Wisniewski
Top achievements
Rank 1
answered on 07 Oct 2010, 12:42 PM
Thank you very much. But I have a diferent problem.
Lets say I have to rows in my grid which I expand with the "+" button.

First I expand the row A, then I expand row B.
Now I click on some control which in the expanded area of row A. The problem is, that row B is still selected.
Any suggestions on that?
0
Maya
Telerik team
answered on 07 Oct 2010, 03:04 PM
Hello Tomasz Wisniewski,

You may take a look at this forum thread for a reference.

Greetings,
Maya
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
Tags
GridView
Asked by
Tomasz Wisniewski
Top achievements
Rank 1
Answers by
Maya
Telerik team
Tomasz Wisniewski
Top achievements
Rank 1
Share this question
or