Hierarchical GridView and current select row

6 posts, 1 answers
  1. Marcin
    Marcin avatar
    186 posts
    Member since:
    Jan 2011

    Posted 28 Mar 2013 Link to this post

    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?
  2. Yoan
    Admin
    Yoan avatar
    1182 posts

    Posted 01 Apr 2013 Link to this post

    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.

  3. Marcin
    Marcin avatar
    186 posts
    Member since:
    Jan 2011

    Posted 02 Apr 2013 Link to this post

    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.
  4. Yoan
    Admin
    Yoan avatar
    1182 posts

    Posted 04 Apr 2013 Link to this post

    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.

  5. Marcin
    Marcin avatar
    186 posts
    Member since:
    Jan 2011

    Posted 04 Apr 2013 Link to this post

    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?
  6. Answer
    Yoan
    Admin
    Yoan avatar
    1182 posts

    Posted 09 Apr 2013 Link to this post

    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.

Back to Top