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

Selecting row when row details are expanded

2 Answers 229 Views
GridView
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 29 May 2012, 08:22 PM
Hi.

I'm using a grid that has row details. There is a plus sign in the left-most column for the user to click on to expand the row. When the user clicks on a cell in the row, the details expand normally and the row is selected. But when the user just clicks on the plus sign, the row is expanded but the row does not get selected. I've tried various ways to programmatically select the row in the RowDetailsVisibilityChanged event but have been unsuccessful.

Also, the showing of the row details when the user clicks on other cells works OK (RowDetailsVisibilityMode = VisibleWhenSelected) but after a while the rows do not expand anymore and the user must click on the plus sign to expand the row. Not sure if the two issues are related.

I'm relatively new to WPF so apologies if I'm overlooking the obvious.

TIA,

John

2 Answers, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 31 May 2012, 02:11 PM
Hello John,

You can subscribe to the expand button's click event and use the handler to add the underlying item to the selected items of the GridView, but the approach you have chosen should work as well.
Would it be possible to share some more information about the exact code you are using in the RowDetailsVisibilityChanged event handler?

Looking forward to your response!  

Regards,
Nik
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
John
Top achievements
Rank 1
answered on 04 Jun 2012, 02:44 PM
Thanks Nik for letting me know I was at least down the right path.

I was able to solve the problem by getting a reference to the row content using the DataContext then finding that element in the collection:

private void radGridViewVendors_RowDetailsVisibilityChanged(object sender, GridViewRowDetailsEventArgs e)
{
    if (e.DetailsElement != null)
    {
        Vendor _vendor = e.DetailsElement.DataContext as Vendor ;
        radGridViewVendors.SelectedItem = companyData[0].companyVendorData.ElementAt(companyData[0].companyVendorData.IndexOf(_vendor));
    }
}

I imagine there could be a more elegant way of handling this, but this approach works for me.

Thanks.
Tags
GridView
Asked by
John
Top achievements
Rank 1
Answers by
Nick
Telerik team
John
Top achievements
Rank 1
Share this question
or