<h2>Master Grid</h2> @(Html.EJ().Grid<object>("MasterGrid") .Datasource(ds => ds.URL("/Home/EmployeeDataSource").Adaptor("UrlAdaptor").BatchURL("/Home/EmployeeUpdate")) .SelectedRowIndex(0) .ClientSideEvents(c => c.RowSelected("rowSelected")) .AllowPaging() .Columns(col => { . . . .
}))
<h2>Detail Grid1</h2> @(Html.EJ().Grid<object>("ChildGrid") .AllowPaging() .Columns(col => { . . . . }) ) <script type="text/javascript"> $(function () { window.rowSelected = function (args) { var dataManger = ej.DataManager({ url: "/Home/OrderDataSource", batchUrl: "/Home/OrderUpdate", adaptor: new ej.UrlAdaptor() }); $("#ChildGrid").ejGrid({ dataSource: dataManger, query: new ej.Query().addParams("EmployeeID", args.data.EmployeeID) }); } });
|
public ActionResult OrderDataSource(DataManager dm, int EmployeeID) { var DataSource = OrderRepository.GetAllRecords().Where(e => e.EmployeeID == EmployeeID); DataResult result = new DataResult(); result.result = DataSource.Skip(dm.Skip).Take(dm.Take).ToList(); result.count = DataSource.Count(); return Json(result, JsonRequestBehavior.AllowGet); |
public ActionResult OrderDataUpdate(List<order> changed, List<order>added, List<order> deleted) { var manager = new Models.DataManager(); if (changed != null) { manager.OrderData.Update(changed); } //if (deleted != null) // OrderData.Delete(deleted); if (added != null) manager.OrderData.Add(added); var data = OrderData.Orders(manager, ""); return Json(data, JsonRequestBehavior.AllowGet); } |
public ActionResult OrderDataUpdate(List<order> changed, List<order>added, List<order> deleted) { var manager = new Models.DataManager();
if (changed != null) { manager.OrderData.Update(changed); } //if (deleted != null) // OrderData.Delete(deleted); if (added != null) manager.OrderData.Add(added); var data = OrderData.Orders(manager, ""); return Json(data, JsonRequestBehavior.AllowGet); } |