There are scenarios in which you may want to present dependent grids (filtering the records in the second grid according to the selection in the first) to enrich the user experience and make the interaction between these grid easier and more intuitive. Telerik RadGrid supports this feature out-of-the-box in a similar means as the MS GridView.
In the demo, the first grid presents Customers, the second grid visualizes the relevant Orders and the third grid shows the Order Details for the selected order.
Here is how to implement this behavior:
- Add the primary key field for the related grid to the DataKeyNames array of the master grid's MasterTableView. It must be the first field in the list.
- Construct a SelectParameter of type ControlParameter for the child grid data source control. Here is how to set its properties:
- ControlID: must point to the ID of the master grid
- Name: must match the primary key value added previously to the master grid
- PropertyName: must be SelectedValue.
- DefaultValue and Type: set them according to your data.
- If you have more than one field name in the DataKeyNames collection of the master grid, use the following setup:
- PropertyName: SelectedValues['<FieldName>'] where <FieldName> represents a column in the data source.
The functionality depicted above is enhanced to be performed with ajax requests (ajaxifying the grids with RadAjaxManager instance, and setting ClientSettings->EnablePostBackOnRowClick = true). The row selection is made through keyboard navigation (check the Accessibility section for more details) or with client selection when row is clicked.