This is a migrated thread and some comments may be shown as answers.

Issues in using events.RequestEnd in kendo grid

3 Answers 1275 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Anne
Top achievements
Rank 1
Anne asked on 09 Apr 2013, 09:54 AM
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>

3 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 09 Apr 2013, 11:58 AM
Hi Anne,

As you may know and as stated in the documentation, the type field value of the requestEnd event raised after a delete operation is destroy instead of remove. Therefore, please correct the function logic accordingly and see if there is a changed in the behavior. 

Regards,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Anne
Top achievements
Rank 1
answered on 09 Apr 2013, 12:44 PM
Hi Rosen,

Thanks for the prompt answer. I think you misunderstood the word 'remove'. I did not mean that the I am using the word 'remove' as a type anywhere in my code. The problem is a don't get back anything in e.type when the control comes to the RequestEnd handler. In the first post I sent the code I have written in the controller action and the grid. Following is the javascript handler for RequestEnd at runtime, please take a look the e.type is undefined in the attachment.
Am I doing anything wrong here?

Thanks
Joydeep
0
Rosen
Telerik team
answered on 09 Apr 2013, 01:02 PM
Hello Joydeep,

The only way to have requestEnd event without type in the described configuration is that the error event is raised beforehand. Thus, the requestEnd is raised from the error handling.

You may know that there is a breaking change with the jQuery 1.9.x which can cause the triggering of error event in similar scenario. Please refer to this forum entry for more details.

Greetings,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Anne
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Anne
Top achievements
Rank 1
Share this question
or