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

RowDetails template and SelectedItem etc

3 Answers 48 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Trump
Top achievements
Rank 1
Trump asked on 06 Feb 2019, 02:57 AM

I want to use RowDetails in the grid. So I want to put a toggle button on the first column, click it will expand or collapse. The question is that I click it the selected Item is not bind. It seems that button is not belonging to the selectedItemUnless I click somewhere else on the row. 

Not sure..how? Sorry I can't provide sample code now...

3 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 08 Feb 2019, 03:36 PM
Hi Trump,

To achieve your requirement you can use the RowDetailsVisibilityChanged event of RadGridView. Here is an example in code:
private void RadGridView_RowDetailsVisibilityChanged(object sender, GridViewRowDetailsEventArgs e)
{
    if (e.Visibility == Visibility.Visible)
    {
        this.gridView.SelectedItems.Add(e.Row.Item);
    }
    else
    {
        this.gridView.SelectedItems.Remove(e.Row.Item);
    }           
}

Regards,
Martin Ivanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Trump
Top achievements
Rank 1
answered on 09 Mar 2019, 01:12 PM
It seems to be working. But can we use MVVM? Because when the template expanding, I want to set a bool property in ViewModel.
0
Martin Ivanov
Telerik team
answered on 13 Mar 2019, 02:22 PM
Hello Trump,

To achieve your requirement you can data bind the DetailsVisibility property of GridViewRow to a property of the view model of the row. To do this you can use the RowStyle property of RadGridView. I've attached a small example showing this approach. Can you please give it a try and let me know how it goes?

Regards,
Martin Ivanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Trump
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Trump
Top achievements
Rank 1
Share this question
or