This example illustrates how to implement the master-detail GridView with editing capabilities.
Follow the steps below to define the master-detail layout:
-
Define master and detail GridView settings in separate PartialView files.
GridViewMasterPartial.cshtml
@Html.DevExpress().GridView( settings => { settings.Name = "masterGrid"; // ... }).Bind(Model).GetHtml()
GridViewDetailPartial.cshtml
@Html.DevExpress().GridView( settings => { settings.Name = "detailGridView_" + ViewData["RoomID"]; // ... }).Bind(Model).GetHtml()
-
Set the master grid's SettingsDetail.ShowDetailRow property to
true
.settings.SettingsDetail.ShowDetailRow = true;
-
Call the master grid's SetDetailRowTemplateContent method to render the detail grid's PartialView in the Detail Row.
settings.SetDetailRowTemplateContent(c => { Html.RenderAction("GridViewDetailPartial", new { RoomID = DataBinder.Eval(c.DataItem, "ID") }); });
Note that route values passed in a detail grid's callback must have a unique name and must not replicate any other names on a page.
- GridView - Advanced Master-Detail View
- A simple example of master-detail grids with editing capabilities
(you will be redirected to DevExpress.com to submit your response)