@Grid
<ej-grid id="FlatGrid" allow-paging="true" allow-filtering="true" allow-selection="true" >
<e-edit-settings allow-adding="true" allow-deleting="true" allow-editing="true" ></e-edit-settings>
<e-toolbar-settings show-toolbar="true" toolbar-items="@(new List<string>() { "add", "edit", "delete", "cancel", "update"})"></e-toolbar-settings>
<e-datamanager url="/Home/DataSource" insert-url="/Home/CellEditInsert" update-url="/Home/CellEditUpdate" remove-url="/Home/CellEditDelete" adaptor="UrlAdaptor"></e-datamanager>
<e-columns>
. . .
</e-columns>
</ej-grid>
@server side code
//Update the data
public ActionResult CellEditUpdate([FromBody]CRUDModel<Orders> value)
{
var ord = value.Value;
Orders val = order.Where(or => or.OrderID == ord.OrderID).FirstOrDefault();
val.OrderID = ord.OrderID;
val.EmployeeID = ord.EmployeeID;
val.CustomerID = ord.CustomerID;
val.Freight = ord.Freight;
val.OrderDate = ord.OrderDate;
val.ShipCity = ord.ShipCity;
return Json(value.Value);
}
//insert the record
public ActionResult CellEditInsert([FromBody]CRUDModel<Orders> value)
{
order.Insert(0, value.Value);
return Json(value);
}
//Delete the record
public ActionResult CellEditDelete([FromBody]CRUDModel<Orders> value)
{
order.Remove(order.Where(or => or.OrderID == int.Parse(value.Key.ToString())).FirstOrDefault());
return Json(value);
} |
@GRID
<ej-grid id="FlatGrid" allow-paging="true" allow-filtering="true" allow-selection="true" >
<e-edit-settings allow-adding="true" allow-deleting="true" allow-editing="true" edit-mode="Batch" ></e-edit-settings>
<e-toolbar-settings show-toolbar="true" toolbar-items="@(new List<string>() { "add", "edit", "delete", "cancel", "update”})"></e-toolbar-settings>
<e-datamanager url="/Home/DataSource" batch-url="/Home/BatchUpdate" adaptor="UrlAdaptor"></e-datamanager>
<e-columns>
. . .
</e-columns>
</ej-grid>
@server side code
public ActionResult BatchUpdate([FromBody]CRUDModel value)
{
//do stuff
} |