Grid Inline Editing Cascade using Parent

GridInlineEditParent/Index.cshtml
@{ var gridId = "gridInlPar"; }

<div class="bar">
<button type="button" onclick="$('#@gridId').data('api').inlineCreate()" class="awe-btn mbtn">Create</button>
</div>

@Html.InitDeletePopupForGrid(gridId, "GridInlineEditDemo")

@(Html.Awe().Grid(gridId)
.Mod(o => o.PageInfo())
.InlEdit(new InlEditOpt { SaveUrl = Url.Action("Save") })
.Url(Url.Action("GridGetItems"))
.Groupable(false)
.Columns(
new Column { Bind = "Id", Width = 75 }
.InlId(),

new Column { Bind = "Category.Name", Header = "Category" }
.InlDropdownList(
new DropdownListOpt
{
Name = "CategoryId",
Url = Url.Action("GetCategories", "Data")
}),

new Column { Bind = "Meal.Name", Header = "Meal" }
.InlDropdownList(
new DropdownListOpt
{
Name = "MealId",
Url = Url.Action("GetMeals", "Data"),
}
.ParentInl("CategoryId", "categories")),

new Column { Bind = "Meals1", Prop="Meals1Names", Header = "Meals1" }
.InlMultiselect(
new MultiselectOpt
{
Name = "Meals1Ids",
Url = Url.Action("GetMeals", "Data"),
}
.ParentInl("CategoryId", "categories")),

Html.InlEditColumn(),
Html.InlDeleteColumn(gridId)))
Awesome/DataController.cs
public IActionResult GetMeals(int[] categories)
{
categories = categories ?? new int[] { };
var items = mcx.Meals.Where(o => categories.Contains(o.Category.Id))
.Select(o => new KeyContent(o.Id, o.Name));

return Json(items);
}



Comments