[view]
@{Html.EJ().Grid<WebApplication8.Controllers.HomeController.Orders>("HierarchyGrid")
.Datasource(ds => ds.Json(this.Model).BatchURL("/Home/BatchUpdate").Adaptor(AdaptorType.RemoteSaveAdaptor))
…..
}
[controller]
//Batch URL
public ActionResult BatchUpdate([FromBody]CRUDModel<Orders> changed, [FromBody]CRUDModel<Orders> added, [FromBody]CRUDModel<Orders> deleted)
{
// do your database here
return View();
}
|
@{
ViewData["Title"] = "Home Page";
}
<h2>Index</h2>
@using WebApplication8.Controllers
@model List<WebApplication8.Controllers.HomeController.Orders>
@{Html.EJ().Grid<WebApplication8.Controllers.HomeController.Orders>("HierarchyGrid")
.Datasource(ds => ds.Json(this.Model).BatchURL("/Home/BatchUpdate").Adaptor(AdaptorType.RemoteSaveAdaptor))
.ShowColumnChooser()
.AllowPaging()
.EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing().EditMode(EditMode.Batch); })
.ToolbarSettings(toolbar =>
{
toolbar.ShowToolbar().ToolbarItems(items =>
{
items.AddTool(ToolBarItems.Add);
items.AddTool(ToolBarItems.Edit);
items.AddTool(ToolBarItems.Delete);
items.AddTool(ToolBarItems.Update);
items.AddTool(ToolBarItems.Cancel);
});
})
.Columns(col =>
{
col.Field("OrderID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(90).ValidationRules(v => v.AddRule("required", true).AddRule("number", true)).Add();
col.Field("CustomerID").HeaderText("Customer ID").Width(90).Add();
col.Field("EmployeeID").HeaderText("Employee ID").TextAlign(TextAlign.Right).Width(90).Add();
col.Field("Freight").HeaderText("Freight").TextAlign(TextAlign.Right).Width(80).EditType(EditingType.Numeric).Format("{0:C}").Add();
}).Render();
}
//
public ActionResult BatchUpdate([FromBody]CRUDModel<Orders> changed, [FromBody]CRUDModel<Orders> added, [FromBody]CRUDModel<Orders> deleted)
{
// do your database here
return View();
}
|