Grid nesting, hierarchy

The awesome grid can have multiple nests, an url or javascript function can be specified for loading the nest content.
When using url the Key of the grid is sent as Key parameter to the url.
The class of the html element that will act as a toggle button for the nest needs to be specified, that element will get classname+"-on" class while its nest is open.
The nest can also be open using the grid api nestOpen(row, class) as shown in the demos below. Opening a nest will close other nests that are open for the same row.

Master detail grid

Using one nest with url to achieve a master detail grid view

using grid api to open, close and toggle open nest for the first row:

new Column { ClientFormat = DemoUtils.DetailNstBtn, Width = 100, Header = "Id" },
new Column { Bind = "Person" },
new Column { Bind = "Food" },
new Column { Bind = "Location" })
.Url(Url.Action("GetItems", "LunchGrid"))
.Nests(new Nest { Name = "detailnst", Url = Url.Action("LunchDetail"), LoadOnce = true }))
<br />
using grid api to open, close and toggle open nest for the first row:
<button type="button" class="awe-btn" id="btnOpenNest">Open nest</button>
<button type="button" class="awe-btn" id="btnCloseNest">Close nest </button>
<button type="button" class="awe-btn" id="btnToggleNest">Toggle nest</button>

$(function () {
var grid = $('#MasterDetailGrid');
var api ='api');

$('#btnToggleNest').click(function () {
api.nestToggle(grid.find('.awe-row:first'), 'detailnst');

$('#btnOpenNest').click(function () {
api.nestOpen(grid.find('.awe-row:first'), 'detailnst');

$('#btnCloseNest').click(function () {
api.nestClose(grid.find('.awe-row:first'), 'detailnst');
public class LunchGridController : Controller
public IActionResult GetItems(GridParams g, string person, string food, int? country)
food = (food ?? "").ToLower();
person = (person ?? "").ToLower();

var list = Db.Lunches
.Where(o => o.Food.ToLower().Contains(food) && o.Person.ToLower().Contains(person))

if (country.HasValue) list = list.Where(o => o.Country.Id == country);

return Json(new GridModelBuilder<Lunch>(list, g)
KeyProp = o => o.Id,// needed for Entity Framework | nesting | tree | api
Map = o => new
Date = o.Date.ToShortDateString(),
CountryName = o.Country.Name,
ChefName = o.Chef.FirstName + " " + o.Chef.LastName
public IActionResult LunchDetail(int key)
var lunch = Db.Get<Lunch>(key);
return PartialView(lunch);
@model AweCoreDemo.Models.Lunch
<div style="padding:0.2em 2em;" class="o-fzcon">
@Model.Person had @Model.Food at @Model.Location in @Model.Country.Name<br/>
View loaded from server at: @DateTime.UtcNow UTC

Nested grids / Hierarchical grid

Hierarchical grid done using the grid nest feature.
The url of the grid nest is set to an action that returns a partial view (created by the user) which contains a grid, the action also receives the key of the row (Id) as a parameter.

.Url(Url.Action("CategoriesGrid", "Data"))
.Columns(new Column { Bind = "Name", ClientFormat = "<div class='detailnst'><i class='caretc'><i class='o-caret o-cl2'></i></i> .(Name)</div> " })
.Nests(new Nest { Name = "detailnst", Url = Url.Action("MealGrid"), LoadOnce = true }))
public IActionResult MealGrid(int key)
ViewData["Id"] = key;
return PartialView();
<div style="margin: 5px;">
@* adding Id to grid name to have unique html ids across all nests*@
@(Html.Awe().Grid("MealsGrid" + ViewData["Id"])
.Url(Url.Action("ChildMealsGrid", "Data"))
new Column {Bind = "Id", Width = 50},
new Column {Bind = "Name", Width = 150},
new Column {Bind = "Description"})
.Parameter("categories", ViewData["Id"]))
public IActionResult CategoriesGrid(GridParams g)
return Json(new GridModelBuilder<Category>(Db.Categories.AsQueryable(), g)
Key = "Id"

public IActionResult ChildMealsGrid(GridParams g, int[] categories)
categories = categories ?? new int[] { };

return Json(new GridModelBuilder<Meal>(Db.Meals
.Where(o => categories.Contains(o.Category.Id)).AsQueryable(), g).Build());

In nest editing grid

Combining the PopupForm, inline popup, and grid nesting to achieve in nest editing. We have 2 nests, both with js functions specified for loading the content, the js func uses the popup api to load the content inside the nest and binds to the popups aweclose event so that the nest will close when the popup closes. All the popups are in the same group so opening a create popup will close other edit/delete popups etc.
var grid3 = "NestDinnersGrid";
@Html.InitCrudForGridNest(grid3, "DinnersGridCrud")

<div class="bar">
<button type="button" onclick="utils.nestCreate('@grid3', 'create@(grid3)')" class="awe-btn mbtn">Create</button>

.Url(Url.Action("GridGetItems", "DinnersGridCrud"))
.Attr("data-syncg", "dinner")
.Mod(o => o.ColumnsAutohide())
new Nest { Name = "editnst", GetFunc = "utils.loadNestPopup('edit" + grid3 + "')" },
new Nest { Name = "delnst", GetFunc = "utils.loadNestPopup('delete" + grid3 + "')" })
new Column { Bind = "Id", Width = 70 },
new Column { Bind = "Name" }.Mod(o => o.NoAutohide()),
new Column { Bind = "Date" },
new Column { Bind = "Chef.FirstName,Chef.LastName", ClientFormat = ".(ChefName)", Header = "Chef" },
new Column { ClientFormat = ".(Meals)", Header = "Meals" },
new Column { ClientFormat = GridUtils.EditGridNestFormat(), Width = 55 }.Mod(o => o.Nohide()),
new Column { ClientFormat = GridUtils.DeleteGridNestFormat(), Width = 55 }.Mod(o => o.Nohide())))

.editnst-on .editnst, .delnst-on .delnst {
outline: gray auto 5px;