@(Html.EJ().Grid<object>("FlatGrid")
.Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.dataSource).UpdateURL("NormalUpdate").InsertURL("NormalInsert").RemoveURL("NormalDelete").Adaptor(AdaptorType.RemoteSaveAdaptor))
.EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); })
.AllowPaging()
-----------------------------
.Columns(col =>
{
-----------------------
})
--------------------------------------------
public ActionResult NormalUpdate(EditableOrder value)
{
OrderRepository.Update(value);
return Json(value, JsonRequestBehavior.AllowGet);
}
public ActionResult NormalInsert(EditableOrder value)
{
OrderRepository.Add(value);
return Json(value, JsonRequestBehavior.AllowGet);
}
public ActionResult NormalDelete(int key)
{
OrderRepository.Delete(key);
return Json(key, JsonRequestBehavior.AllowGet);
} |
@(Html.EJ().Grid<object>("FlatGrid")
.Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.dataSource).UpdateURL("NormalUpdate").InsertURL("NormalInsert").RemoveURL("NormalDelete").Adaptor(AdaptorType.RemoteSaveAdaptor))
.EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); })
.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.remoteSaveAdaptor().extend({
remove: function (dm, keyField, value, tableName, query) {
var grid = $("#FlatGrid").ejGrid("instance");
var record = grid.getSelectedRecords()[0];
return {
url: dm.dataSource.removeUrl,
type: "POST",
contentType: "application/json; charset=utf-8",
dataType: "json",
data: JSON.stringify({ "value": (record) })
};
}
});
</script> |
How to get value from datepicker placed in grid for insert and update?
I am getting the selected date value as "2017-07-10T18:30:00.000Z" when i choose 11/07/2017(dd/MM/yyyy)
I have used inline template
$("#datepicker").ejDatePicker(); // Create DatePicker instance dateObj = $("#datepicker").data("ejDatePicker"); dateObj.getValue(); // returns the date value |