@(Html.EJ().Grid<object>("FlatGrid")
.Datasource((IEnumerable<object>)ViewBag.datasource)
.AllowPaging()
.Columns(col =>
{
----------------------
})
.ClientSideEvents(eve => { eve.Create("create"); })
)
<script>
function create(args) {
$("#FlatGrid").prepend("<div>" + new Date() + "</div>");
}
</script> |
@(Html.EJ().Grid<object>("FlatGrid")
.Datasource((IEnumerable<object>)ViewBag.datasource)
.AllowPaging()
--------------------------------------------
.Columns(col =>
{
-----------------------------------
})
.ClientSideEvents(eve => { eve.Create("create").ToolbarClick("toolbar"); })
)
<script>
function create(args) {
$("#FlatGrid").prepend("<div id='Date'>" + new Date() + "</div>");
}
function toolbar(args) {
if (args.itemName == "Update") {
$.ajax({
url: "/Grid/Save",
type: "POST",
dataType: "json",
contentType: "application/json;charset=utf-8",
data: JSON.stringify({ "value": $("#Date").text() }),
success: function (e) {
var a = e;
}
});
}
}
</script>
-----------------------------------------------------
public ActionResult Save(string value)
{
return Json(value, JsonRequestBehavior.AllowGet);
}
|
@(Html.EJ().Grid<object>("FlatGrid")
.Datasource(d => d.URL("/Home/GetData").BatchURL("/Home/BatchUpdate").Adaptor(AdaptorType.UrlAdaptor))
.EditSettings(edit => edit.AllowEditing().EditMode(EditMode.Batch))
------------------------------
.AllowPaging()
.Columns(col =>
{
col.Field("OrderID").HeaderText("OrderID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add();
col.Field("ShipCity").Width(100).Add();
col.Field("ShipCountry").Width(100).Add();
})
.ClientSideEvents(eve => { eve.Create("create").Load("load"); })
)
<script>
function create(args) {
$("#FlatGrid").prepend("<div id='Date'>" + new Date() + "</div>");
}
function load(args) {
this.model.dataSource.adaptor = new customAdaptor();
}
var customAdaptor = new ej.UrlAdaptor().extend({
batchRequest: function (dm, changes, e, query) {
var res = {
changed: changes.changed,
added: changes.added,
deleted: changes.deleted,
action: "batch",
table: e.url,
value: $("#Date").text(),
key: e.key
};
-------------------------
return {
type: "POST",
url: dm.dataSource.batchUrl,
contentType: "application/json; charset=utf-8",
dataType: "json",
data: JSON.stringify(res)
};
}
});
</script> |