BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
@(Html.EJ().Grid<object>("FlatGrid")
.Datasource((IEnumerable<object>)ViewBag.datasource)
.AllowSorting() /*Sorting Enabled*/
.AllowPaging() /*Paging Enabled*/
.EditSettings(edit => edit.AllowAdding().AllowEditing().AllowDeleting())
.ClientSideEvents(eve =>
{
eve.EndAdd("endAdd");
eve.EndEdit("endEdit");
eve.EndDelete("endDelete");
})
.ToolbarSettings(tool => tool.ShowToolbar().ToolbarItems(items =>
{
items.AddTool(ToolBarItems.Add);
items.AddTool(ToolBarItems.Edit);
items.AddTool(ToolBarItems.Cancel);
items.AddTool(ToolBarItems.Update);
items.AddTool(ToolBarItems.Delete);
items.AddTool(ToolBarItems.Search);
}))
.Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add();
col.Field("CustomerID").HeaderText("Customer ID").Width(80).Add();
col.Field("EmployeeID").HeaderText("Employee
})
)
|
<script type="text/javascript">
function endEdit(args) {
$.ajax({
url: "/Grid/Update",
type: "POST",
contentType: "application/json",
data: JSON.stringify({ value: args.data }),
success: function (value) {
$("#Grid").ejGrid("dataSource", value);
alert("Save Complete")
},
error: function (xhr) {
alert('error');
}
});
}
function endAdd(args) {
$.ajax({
url: "/Grid/Insert",
type: "POST",
contentType: "application/json",
data: JSON.stringify({ value: args.data }),
success: function (value) {
$("#Grid").ejGrid("dataSource", value);
alert("Add Complete")
},
error: function (xhr) {
alert('error');
}
});
}
function endDelete(args) {
$.ajax({
url: "/Grid/Delete",
type: "POST",
contentType: "application/json",
data: JSON.stringify({ key: args.data.OrderID }),
success: function (value) {
$("#Grid").ejGrid("dataSource", value);
alert("Delete Complete")
},
error: function (xhr) {
alert('error');
}
})
}
</script>
|
public ActionResult Update(EditableOrder value)
{
OrderRepository.Update(value);
var data = OrderRepository.GetAllRecords();
return Json(value, JsonRequestBehavior.AllowGet);
}
public ActionResult Insert(EditableOrder value)
{
OrderRepository.Add(value);
var data = OrderRepository.GetAllRecords();
return Json(value, JsonRequestBehavior.AllowGet);
}
public ActionResult Delete(int key)
{
OrderRepository.Delete(key);
var data = OrderRepository.GetAllRecords();
return Json(data, JsonRequestBehavior.AllowGet);
}
|