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

Selecting a Child Row in a Hierarchical RadGrid Programmatically

1 Answer 242 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jonathan
Top achievements
Rank 1
Jonathan asked on 24 Dec 2010, 04:00 PM
Hi,

I'm using RadControls version: 2010.Q3.1109.

I'm trying to select a child row in a Hierarchical RadGrid programmatically, but I'm having a world of woes. I've scoured Telerik's resources and this forum and I haven't seen an example of this for the RadAJAX Grid control.

Here's the code I'm trying to use:

RadGrid3.MasterTableView.Items(j).ChildItem.NestedTableViews(0).Items(i).Selected = True

However, I'm getting an ArgumentOutOfRangeException when I use this code, even when I set:

RadGrid3.MasterTableView.Items(j).ChildItem.NestedTableViews(0).HierarchyDefaultExpanded = True

The values for integer variables j and i are perfectly valid. If I should use:

RadGrid3.MasterTableView.HierarchyDefaultExpanded = True

...then it will work, but then every child record of every parent record in the table is expanded and that's not what I want. I only want the one parent record to be expanded — not all of them.

I can select the parent record just fine with:

RadGrid3.MasterTableView.Items(j).Selected = True

I'm at wits end. Your help would be greatly appreciated.

Jonathan

1 Answer, 1 is accepted

Sort by
0
Jonathan
Top achievements
Rank 1
answered on 24 Dec 2010, 04:28 PM
Ok, I solved the problem. All I had to do was this:

RadGrid3.MasterTableView.Items(j).FireCommandEvent("ExpandCollapse", String.Empty)

before I called this:

RadGrid3.MasterTableView.Items(j).ChildItem.NestedTableViews(0).Items(i).Selected = True

This expands only the parent record in question instead of expanding all the parent records with HierarchyDefaultExpanded.

Hopefully this will be useful to someone.

Regards,
Jonathan.
Tags
Grid
Asked by
Jonathan
Top achievements
Rank 1
Answers by
Jonathan
Top achievements
Rank 1
Share this question
or