<ej-grid id="Grid" allow-filtering="true" allow-paging="true">
<e-datamanager json="(IEnumerable<object>)ViewBag.data"
update-url="/Home/CellEditUpdate"
insert-url="/Home/CellEditInsert"
remove-url="/Home/CellEditDelete"
adaptor="remoteSaveAdaptor" />
. . . . .
</ej-grid>
public IActionResult Index()
{
BindDataSource();
ViewBag.data = order;
return View();
}
public ActionResult CellEditUpdate([FromBody]CRUDModel<Orders> value)
{
var ord = value.Value;
Orders val = order.Where(or => or.OrderID == ord.OrderID).FirstOrDefault();
val.EmployeeID = ord.EmployeeID;
val.CustomerID = ord.CustomerID;
. . . .
return Json(value.Value);
}
public ActionResult CellEditInsert([FromBody]CRUDModel<Orders> value)
{
value.Value.OrderID =order.LastOrDefault().OrderID + 1;
order.Insert(0, value.Value);
return Json(value);
} |
<ej-grid id="Grid" allow-filtering="true" allow-paging="true">
<e-datamanager json="(IEnumerable<object>)ViewBag.data"
update-url="/Home/CellEditUpdate"
insert-url="/Home/CellEditInsert"
remove-url="/Home/CellEditDelete"
adaptor="remoteSaveAdaptor" />
. . .
<e-columns>
<e-column field="OrderID" is-primary-key="true" is-identity="true" visible="false" />
. . . .
</e-columns>
</ej-grid>
public ActionResult CellEditInsert([FromBody]CRUDModel<Orders> value)
{
value.Value.OrderID =order.LastOrDefault().OrderID + 1;
order.Insert(0, value.Value);
return Json(value);
} |