BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
public ActionResult Insert([FromBody]OrdersView value)
{
value.OrderID = ++count; //Auto increment the value for isIdnetity property
order.Add(value);
return Json(value, JsonRequestBehavior.AllowGet);
} |
@Grid
@{Html.EJ().Grid<WebApplication8.Controllers.HomeController.Orders>("Editing")
.Datasource(ds => ds.URL(@Url.Action("DataSource")).UpdateURL("/Home/CellEditUpdate")
.InsertURL("/Home/CellEditInsert").RemoveURL("/Home/CellEditDelete").Adaptor(AdaptorType. RemoteSaveAdaptor))
.Columns(col =>
{
col.Field("OrderID").IsPrimaryKey(true) .IsIdentity(true).TextAlign(TextAlign.Right).Width(90).Add();
. . .
}).ClientSideEvents(e=>e.ActionBegin("actionBegin"))
.Render();
}
@ActionBegin event
<script type="text/javascript">
var flag=false, count=100;
function actionBegin(args) {
if (args.requestType == "add")
flag = true;
//Set the isIdentity value while inserting the record
if (flag && args.requestType == "save") {
args.data.OrderID = count++;// here OrderID is the isIdentity field and set the value while inserting the record
flag = false;
}
}
</script> |
<input type="button" value="Grid Refresh" id="refresh"/>
@{Html.EJ().Grid<WebApplication8.Controllers.HomeController.Orders>("Editing")
.Datasource(ds => ds.URL(@Url.Action("DataSource")).UpdateURL("/Home/CellEditUpdate") .InsertURL("/Home/CellEditInsert").RemoveURL("/Home/CellEditDelete").Adaptor(AdaptorType. RemoteSaveAdaptor))
.Columns(col =>
{
. . .
})
.Render();
}
//Refresh the Grid using button click
$("#refresh").ejButton({
click: function () {
var gridObj = $("#Grid").ejGrid("instance");
gridObj.refreshContent(); //Refresh the Grid by calling the refreshContent method
}
}); |