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

Need access to Parent Cells in Grid Hierarchy: *.aspx

2 Answers 71 Views
Grid
This is a migrated thread and some comments may be shown as answers.
pgodard
Top achievements
Rank 1
pgodard asked on 16 Dec 2010, 02:56 PM
I am using the following code to select the parent row. I need to do this when the item is expanded but it's working only on collapse How do I make work on expand.
Private Sub RadGrid1_ItemCommand([source] As Object, e As Telerik.WebControls.GridCommandEventArgs) Handles RadGrid1.ItemCommand
   If e.CommandName = RadGrid.ExpandCollapseCommandName Then
      Dim item As GridItem
      For Each item In e.Item.OwnerTableView.Items
          If item.Expanded  Then
            item.Selected = True
          End If
      Next item
   End If
End Sub 'RadGrid1_ItemCommand 

Alternately, does or can Telerik provide an option to do this. When a Parent row in a Grid Hierchy is expanded automacally select the row if row selection is tuened on (multiple or single)

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 17 Dec 2010, 06:05 AM
Hello Pgodard,

The following code snippet shows how to select a row when it is expanding.

VB.NET:
Protected Sub RadGrid1_ItemCommand(sender As Object, e As GridCommandEventArgs)
    If e.CommandName = RadGrid.ExpandCollapseCommandName Then
        Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
        item.Selected = Not item.Expanded
    End If
End Sub

Thanks,
Princy.
0
Pierre
Top achievements
Rank 1
answered on 17 Dec 2010, 08:15 PM
Thanks Princy. The code works, I would also add that the following must be true:

 

<MasterTableView HierarchyLoadMode="ServerOnDemand"

 

<

 

ClientSettings AllowExpandCollapse="True">
    <Selecting AllowRowSelect="True"></Selecting>
</ClientSettings>

 

Tags
Grid
Asked by
pgodard
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Pierre
Top achievements
Rank 1
Share this question
or