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

Expand and collapse nested grid with a parent row click

1 Answer 187 Views
GridView
This is a migrated thread and some comments may be shown as answers.
daddo
Top achievements
Rank 1
daddo asked on 18 May 2016, 10:14 AM
I have a nested grid and I want to expand it and collapse it with a parent row click. It expands with parent row click per default but if i want to close it (collapse it) i have to hold crtl. I want to be able to collapse it again on the parent row click without holding crtl button. How is that possible? Thanks

1 Answer, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 20 May 2016, 07:51 AM
Hello,

You can change the visibility of the RowDetails manually like so:
this.clubsGrid.AddHandler(GridViewDataControl.MouseLeftButtonDownEvent, new MouseButtonEventHandler(OnLeftButtonDown), true);
    }
 
    private void OnLeftButtonDown(object sender, MouseButtonEventArgs e)
    {
        var row = (e.OriginalSource as FrameworkElement).ParentOfType<GridViewRow>();
        if (row != null)
        {
            if (row.DetailsProvider.Visibility == Visibility.Visible)
            {
                row.DetailsVisibility = Visibility.Collapsed;
                 
            }
            else
            {
                row.DetailsVisibility = Visibility.Visible ;
 
            }
        }
    }


Regards,
Yoan
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
GridView
Asked by
daddo
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Share this question
or