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

Hierarchical GridView and current select row

5 Answers 279 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Marcin
Top achievements
Rank 1
Veteran
Marcin asked on 28 Mar 2013, 11:03 AM
Hello
I have problem with finding out if selected or cliked row is on child grid or on parent grid. I want only know if I just clicked/selected child or parent.

I tried selection changed but it is called during expanding row, not during real selection. So e.g when I have only one row in child grid, and switching between parent row and child row, there is no selection changed event fired, So I cannot recognize if my current selected row is on parent grid or on child.

Is there any way to know which row is actually selected? Parent or child?

5 Answers, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 01 Apr 2013, 06:16 AM
Hi Marcin,

Indeed, you can subscribe to the SelectionChanged event and execute the following code:

private void clubsGrid_SelectionChanged(object sender, SelectionChangeEventArgs e)
        {
            if (e.OriginalSource == this.clubsGrid)
            {
                MessageBox.Show("Parent");
            }
            else { MessageBox.Show("Child"); }
        }
Where, "clubsGrid" is the parent RadGridView.

However, I am not sure that this would work for you. Would it be possible to share your main goal? In other words, why do you need to know which row is from the parent and which row is from the child grid?


Kind regards,
Yoan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Marcin
Top achievements
Rank 1
Veteran
answered on 02 Apr 2013, 09:34 AM
The problem with your answer is that event is not fired if I have 1 row parent and 1 row child and switch between these rows..

I would like to have access to data bellow that row on mounse double clikc (to diplay different context menu) get seleted one from button click - I need to know which one is currently seletced parent or child to do different button action or mouse double click action.
0
Yoan
Telerik team
answered on 04 Apr 2013, 08:35 AM
Hi Marcin, 

Please find attached a sample project. If you double click the row in the child RadGridView , a message box with info on the clicked item will appear. Moreover, you can handle Opening event of RadContextMenu and depending on the type of the underlying item, to display only the RadMenuItem you want.

Is it more suitable for your scenario?

Greetings,
Yoan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Marcin
Top achievements
Rank 1
Veteran
answered on 04 Apr 2013, 12:07 PM
Hello,
Thank you,
However I have one more thing to solve:
External button, disable if child selected, enable if parent or
if current row is parent the get taht parent and do action and the same for child. The clue here is button that has no information what was clicked or select using keyboard on grid. How to get access to proper item?
0
Accepted
Yoan
Telerik team
answered on 09 Apr 2013, 11:20 AM
Hi Marcin,

Can you please try to bind the IsEnabled property of the button to a property of your business object and set its value.

All the best,
Yoan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

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