public ActionResult BatchUpdate([FromBody]CRUDModel<OrderDetails> myObject)
{
if (myObject.Changed != null && myObject.Changed.Count > 0)
{
foreach (var temp in myObject.Changed)
{
var ord = temp;
. . .
}
}
var data = orddata;
return Json(data);
} |
When is selected row and pressed button delete, if not send request, how the server will know ?
Or I need to create event for button delete to send request ?
And how to get only edited column on the server, because data.Changed shows me a lot of data like , first column, last column, but not edited column ?
<div id="Grid"></div>
<script>
$(function () {
var dataManager = ej.DataManager({
url: "/Home/get",
insertUrl: "/Home/CellEditInsertDetail",
updateUrl: "/Home/CellEditUpdateDetail",
removeUrl: "/Home/CellEditDeleteDetail",
adaptor: new ej.UrlAdaptor()
});
$("#Grid").ejGrid({
dataSource: dataManager,
allowPaging: true,
editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true },
});
});
</script>
public ActionResult CellEditInsertDetail([FromBody]CRUDModel<OrderDetails> value)
{
orddata.Add(value.Value);
return Json(value.Value);
}
public ActionResult CellEditUpdateDetail([FromBody]CRUDModel<OrderDetails> value)
{
OrderDetails ord = value.Value;
OrderDetails val = orddata.Where(or => or.OrderID == ord.OrderID).FirstOrDefault();
val.EmployeeID = ord.EmployeeID;
. .
. .
return Json(value.Value);
}
public ActionResult CellEditDeleteDetail([FromBody]CRUDModel<OrderDetails> value)
{
OrderDetails ord = orddata.Where(or => or.OrderID == int.Parse(value.Key.ToString())).FirstOrDefault();
orddata.Remove(ord);
return Json(value);
} |