Nesting Grids

Docs

A child grid can be added to the parent grid as a nested grid which is displayed adjacent to the parent row. To add a nested grid simply create the instance of the control and assign the reference of the child grid control to the NestedGrid property of the parent grid control. You will also need to specify which column in the child grid is the ForeignKey which is matched against the PrimaryKey in the parent control.

Razor
                                
                                        
DbNetGridCore customersGrid = new DbNetGridCore("northwind", "customers");
customersGrid.Columns = new List() { "CustomerID", "CompanyName", "Address", "City" };
customersGrid.Column("CustomerID").Hidden();

DbNetGridCore ordersGrid = new DbNetGridCore("northwind", "orders");
ordersGrid.ToolbarPosition = ToolbarPosition.Hidden;
ordersGrid.Columns = new List() { "OrderID", "CustomerID", "EmployeeID", "OrderDate", "RequiredDate", "ShippedDate", "ShipVia", "Freight", "ShipName", "ShipAddress", "ShipCity", "ShipRegion", "ShipPostalCode", "ShipCountry" };
ordersGrid.Column("CustomerID").ForeignKey().Hidden();
ordersGrid.Column("EmployeeID").Lookup(new Lookup("Employees", "EmployeeId", "lastname + ',' + firstname")).Label("Employee");
ordersGrid.Column("ShipVia").Lookup(new Lookup("Shippers", "ShipperId", "CompanyName"));

customersGrid.NestedGrid = ordersGrid;

DbNetGridCore orderDetailsGrid = new DbNetGridCore("northwind", "[order details]");
orderDetailsGrid.ToolbarPosition = ToolbarPosition.Hidden;
orderDetailsGrid.Columns = new List() { "OrderID", "ProductID", "Quantity", "UnitPrice" };
orderDetailsGrid.Column("OrderID").ForeignKey().Hidden();        
orderDetailsGrid.Column("unitprice").Format("c");
orderDetailsGrid.Column("discount").Format("P");
orderDetailsGrid.Column("ProductID").Lookup(new Lookup("Products", "ProductId", "ProductName")).Label("Product");

ordersGrid.NestedGrid = orderDetailsGrid;

@customersGrid.Render()