@(Html.EJ().Grid<object>("Grid")
.Datasource(ds => ds.URL("/Home/DataSource").Adaptor("UrlAdaptor").CrudURL("/Home/Update"))
.EditSettings(edit => { edit.AllowEditing().AllowAdding().AllowDeleting(); })
.AllowPaging()
.ToolbarSettings(toolbar =>
{
toolbar.ShowToolbar().ToolbarItems(items =>
{
items.AddTool(ToolBarItems.Add);
items.AddTool(ToolBarItems.Edit);
items.AddTool(ToolBarItems.Delete);
items.AddTool(ToolBarItems.Update);
items.AddTool(ToolBarItems.Cancel);
});
})
.Columns(col =>
{
--------------------------------------------
})
.ClientSideEvents(eve => { eve.Load("load"); })
)
<script type="text/javascript">
function load(args) {
this.model.dataSource.adaptor = new customAdaptor();
}
var customAdaptor = new ej.UrlAdaptor().extend({
processResponse: function (data, ds, query, xhr, request, changes) {
if (data.success != undefined)
alert(data.success);
var obj = ej.UrlAdaptor.prototype.processResponse(data, ds, query, xhr, request, changes);
return obj;
},
});
</script>
------------------------------------------------------------------------
public ActionResult Update(EditableOrder value)
{
OrderRepository.Update(value);
var data = OrderRepository.GetAllRecords();
if (value.Freight != null)
return Json(new { result = data, success = "success" }, JsonRequestBehavior.AllowGet);
else
return Json(new { result = data, success = "failure" }, JsonRequestBehavior.AllowGet);
}
|