Hi,
I have a very simple requirement of displaying a success message when an item is successfully deleted from the system on the server. In the action result for Destroy command I return the following
return Json(ModelState.ToDataSourceResult(), JsonRequestBehavior.AllowGet);
In case of any known error scenario I add a ModelError to the ModelState and catch it in the event.error handler of kendo grid which works fine. But now I need to handle the success and display a user friendly information. I read through the blogs and found that we can use RequestEnd event handler and check for e.type == "remove". I have implemented accordingly, but in no scenarios I get the TYPE property of "e" back with a valid value on it. It always comes back 'undefined'. Following is the snapshot of the grid I use. Please can someone guide if I am going wrong somewhere or missing something. Version of kendo used is 2013.1.319
<div>
@(Html.Kendo().Grid<WorkTemplateDto>()
.Name("Grid1")
.Columns(columns =>
{
columns.Bound(col => col.Column1).Hidden(true);
columns.Bound(col => col.Column2);
columns.Bound(col => col.Column3);
columns.Bound(col => col.Column4).ClientTemplate(@" #=displayhtmlInGrid(Objective)# ");
columns.Bound(col => col.Column5).Format("{0:dd/MM/yyyy HH:mm:ss}");
columns.Bound(col => col.Column6);
columns.Bound(col => col.Column7).Hidden(true);
columns.Command(command => command.Destroy())
.Hidden(true)
.IncludeInMenu(false);
columns.Bound(x => x.Id)
.Width(50)
.HeaderTemplate(@"<span onclick=""javascript:DisplayDeleteLinksOnGrid();""><img src=""/Content/Images/delete.png"" alt=""Delete"" style=""cursor: pointer;"" /></span>")
.IncludeInMenu(false)
.Sortable(false)
.Groupable(false)
.Filterable(false)
.ClientTemplate(@"<a class=""k-button-icontext k-grid-delete"" style=""display: none;""><img src=""/Content/Images/delete.png"" alt=""Delete"" /></a>");
})
.Groupable()
.Resizable(resize => resize.Columns(true))
.Pageable(pages => pages
.PageSizes(true)
.Refresh(true)
)
.Sortable()
.Scrollable()
.Reorderable(order => order.Columns(true))
.ColumnMenu(menu => menu.Columns(true))
.DataSource(datasource => datasource
.Ajax()
.Model(model => model.Id(p => p.Id))
.Events(events => {
events.Error("griderrorHandler");
events.RequestEnd("onRequestEnd");
})
.Read(action => action.Action("AjaxListSource", "Contoller1"))
.Destroy(action => action.Action("Delete", "Contoller1"))
)
.Selectable(selectable =>
{
selectable.Mode(GridSelectionMode.Single);
selectable.Enabled(true);
selectable.Type(GridSelectionType.Row);
}
)
.Events(e => {
e.Change("gridchangeEvent");
})
)
</div>
I have a very simple requirement of displaying a success message when an item is successfully deleted from the system on the server. In the action result for Destroy command I return the following
return Json(ModelState.ToDataSourceResult(), JsonRequestBehavior.AllowGet);
In case of any known error scenario I add a ModelError to the ModelState and catch it in the event.error handler of kendo grid which works fine. But now I need to handle the success and display a user friendly information. I read through the blogs and found that we can use RequestEnd event handler and check for e.type == "remove". I have implemented accordingly, but in no scenarios I get the TYPE property of "e" back with a valid value on it. It always comes back 'undefined'. Following is the snapshot of the grid I use. Please can someone guide if I am going wrong somewhere or missing something. Version of kendo used is 2013.1.319
<div>
@(Html.Kendo().Grid<WorkTemplateDto>()
.Name("Grid1")
.Columns(columns =>
{
columns.Bound(col => col.Column1).Hidden(true);
columns.Bound(col => col.Column2);
columns.Bound(col => col.Column3);
columns.Bound(col => col.Column4).ClientTemplate(@" #=displayhtmlInGrid(Objective)# ");
columns.Bound(col => col.Column5).Format("{0:dd/MM/yyyy HH:mm:ss}");
columns.Bound(col => col.Column6);
columns.Bound(col => col.Column7).Hidden(true);
columns.Command(command => command.Destroy())
.Hidden(true)
.IncludeInMenu(false);
columns.Bound(x => x.Id)
.Width(50)
.HeaderTemplate(@"<span onclick=""javascript:DisplayDeleteLinksOnGrid();""><img src=""/Content/Images/delete.png"" alt=""Delete"" style=""cursor: pointer;"" /></span>")
.IncludeInMenu(false)
.Sortable(false)
.Groupable(false)
.Filterable(false)
.ClientTemplate(@"<a class=""k-button-icontext k-grid-delete"" style=""display: none;""><img src=""/Content/Images/delete.png"" alt=""Delete"" /></a>");
})
.Groupable()
.Resizable(resize => resize.Columns(true))
.Pageable(pages => pages
.PageSizes(true)
.Refresh(true)
)
.Sortable()
.Scrollable()
.Reorderable(order => order.Columns(true))
.ColumnMenu(menu => menu.Columns(true))
.DataSource(datasource => datasource
.Ajax()
.Model(model => model.Id(p => p.Id))
.Events(events => {
events.Error("griderrorHandler");
events.RequestEnd("onRequestEnd");
})
.Read(action => action.Action("AjaxListSource", "Contoller1"))
.Destroy(action => action.Action("Delete", "Contoller1"))
)
.Selectable(selectable =>
{
selectable.Mode(GridSelectionMode.Single);
selectable.Enabled(true);
selectable.Type(GridSelectionType.Row);
}
)
.Events(e => {
e.Change("gridchangeEvent");
})
)
</div>