RadGrid for ASP.NET

Conditional row select in hierarchy Send comments on this topic.
Selecting grid items > How-to > Conditional row select in hierarchy

Glossary Item Box

If you have a hierarchical grid with a master table and one detail table. You want to allow users to select (client-side) rows at the detail level, but not the master level.  You can hook the RowSelecting event of Telerik RadGrid and return false from the respective event handler if the selection is made within the MasterTableView.
For this purpose, you can check the value for the Name property of the active GridTableView (which has to be previously set for the master and the detail table). Note that this property is serialized by the grid in order to be accessed client-side (attribute of the RadGridTable client grid object).

Note that this approach is applicable with more levels of hierarchy as well.

ASPX/ASCX Copy Code
<script type="text/javascript">
function RowSelecting(row)
{
 if(this.Name == "Customers")
 {
  return false;
 }
}
</script><rad:radgrid id="RadGrid1" runat="server" AllowMultiRowSelection="False">
<MasterTableView DataKeyNames="CustomerID" VirtualItemCount="0" AutoGenerateColumns="False"
AllowPaging="True" AllowSorting="True" PageSize="3" Width="100%" Name="Customers">
 
<Columns>
  
<rad:GridBoundColumn HeaderText="CustomerID" DataField="CustomerID"
  
HeaderButtonType="TextButton" UniqueName="CustomerID"
  
SortExpression="CustomerID" />
  
<rad:GridBoundColumn HeaderText="Contact Name" DataField="ContactName" HeaderButtonType="TextButton"
  
UniqueName="ContactName" SortExpression="ContactName" />
  
<rad:GridBoundColumn HeaderText="Company" DataField="CompanyName" HeaderButtonType="TextButton"
  
UniqueName="CompanyName" SortExpression="CompanyName" />
 
</Columns>
<DetailTables>
 
<rad:GridTableView DataKeyNames="OrderID" AutoGenerateColumns="False" AllowPaging="True"
 
AllowSorting="True" DataMember="Orders" PageSize="3" GridLines="Horizontal" Width="100%" Name="Orders">
 
<ParentTableRelation>
  
<rad:GridRelationFields DetailKeyField="CustomerID"
  
MasterKeyField="CustomerID"></rad:GridRelationFields>
 
</ParentTableRelation>
  
<Columns>
   
<rad:GridBoundColumn HeaderText="OrderID" DataField="OrderID" HeaderButtonType="TextButton" UniqueName="OrderID"
   
SortExpression="OrderID"></rad:GridBoundColumn>
   
<rad:GridBoundColumn HeaderText="Date Ordered" DataField="OrderDate" HeaderButtonType="TextButton" UniqueName="OrderDate"
   
SortExpression="OrderDate"></rad:GridBoundColumn>
   
<rad:GridBoundColumn HeaderText="EmployeeID" DataField="EmployeeID" HeaderButtonType="TextButton" UniqueName="EmployeeID"
   
SortExpression="EmployeeID"></rad:GridBoundColumn>
  
</Columns>
 
</rad:GridTableView>
</DetailTables>
<ExpandCollapseColumn ButtonType="ImageButton" UniqueName="ExpandColumn">
 
<HeaderStyle Width="19px"></HeaderStyle>
 
</ExpandCollapseColumn>
</MasterTableView>
<ClientSettings>
 
<Selecting AllowRowSelect="True"></Selecting>
 
<ClientEvents OnRowSelecting="RowSelecting"></ClientEvents>
</ClientSettings>
</
rad:radgrid>