<ejs-grid id="GridOverview" allowFiltering="true" allowSorting="true"
toolbar="@(new List<string>() {"Update", "Cancel"})" rowHeight="38" enableHover="true" allowSelection="true">
<e-data-manager json="@ViewBag.data.ToArray()" adaptor="RemoteSaveAdaptor" batchUrl="/Home/BatchUpdate"></e-data-manager>
<e-grid-filtersettings type="Menu"></e-grid-filtersettings>
<e-grid-editSettings allowEditing="true" mode="Batch"></e-grid-editSettings>
<e-grid-selectionsettings persistSelection="true" type="Multiple" checkboxOnly="true"></e-grid-selectionsettings>
<e-grid-columns>
<e-grid-column field="OrderID" headerText="Order ID" isPrimaryKey="true" width="75" visible="false"></e-grid-column>
<e-grid-column field="Freight" allowEditing="true" headerText="Freight" width="75" allowFiltering="false" validationRules="@(new { required=true})"></e-grid-column>
<e-grid-column field="RatePerMinute" template="#coltemplate" headerText="Rate Per Minute" allowSorting="true" width="75" allowEditing="false" allowFiltering="false"></e-grid-column>
</e-grid-columns>
</ejs-grid>
<script id="coltemplate" type="text/template">
<span>${format(data)}</span>
</script>
<script type="text/javascript">
var format = function (value) {
var count = value.Freight;
var minutes =2;
return (count / minutes).toFixed(2);
}
</script> |
public IActionResult BatchUpdate([FromBody]CRUDModel<OrdersDetails> batchmodel)
{
if (batchmodel.Changed != null)
{
for (var i = 0; i < batchmodel.Changed.Count(); i++)
{
var ord = batchmodel.Changed[i];
OrdersDetails val = orddata.Where(or => or.OrderID == ord.OrderID).FirstOrDefault();
val.OrderID = ord.OrderID;
val.EmployeeID = ord.EmployeeID;
val.CustomerID = ord.CustomerID;
val.Freight = ord.Freight;
}
}
if (batchmodel.Deleted != null)
{
for (var i = 0; i < batchmodel.Deleted.Count(); i++)
{
orddata.Remove(orddata.Where(or => or.OrderID == batchmodel.Deleted[i].OrderID).FirstOrDefault());
}
}
if (batchmodel.Added != null)
{
for (var i = 0; i < batchmodel.Added.Count(); i++)
{
orddata.Insert(0, batchmodel.Added[i]);
}
}
var data = orddata.ToList();
return Json(batchmodel);
}
|