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

kendo UI grid Change event is firing twice

4 Answers 175 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
santhosh
Top achievements
Rank 1
santhosh asked on 19 Nov 2013, 11:07 PM
I`m binding data via Ajax to grid. I added Change event to the grid. what happening is code inside the Onchange event is executing twice .
I have ajax call inside the Change event function , how can I control this ?  My requirement is I should able to write an event that fires at row level like row select event.


 @(Html.Kendo().Grid<User>()
      .Name("grid")
      .DataSource(datasource => datasource
          .Ajax()
          .ServerOperation(false)
          .Model(model => model.Id(p => p.UserID))
          .Read(read => read.Action("AllUserRecords_Read", "User"))
          .PageSize(15)

      )
      .Columns(columns =>
      {
          columns.Bound(p => p.FirstName).Width(40);
          columns.Bound(p => p.LastName).Width(80);
          columns.Bound(p => p.EmailAddress).Width(70);
       })
      .Pageable(pageable => pageable.PreviousNext(true).PageSizes(new[] { 5, 10, 15, 20 }))
      .Filterable()
      .Events(events => events.DataBound("onDataBound").Change("grid_change"))
      .Selectable(select => select.Mode(GridSelectionMode.Single))
      .Resizable(resize => resize.Columns(true))
      .Reorderable(reorder => reorder.Columns(true)))

 function grid_change(e) {
            $.ajax({
                type: "POST",
                url: "/User/GetRoles",
                data: { userID: id },
                async: false,
                success: function (response) {
                    $("#roles").replaceWith(response);
                },
                error: function (response, q, t) {
                    alert(response.responseText);
                }
            });
 function onDataBound(arg) {
        this.element.find('tbody tr:first').addClass('k-state-selected');
}
}

4 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 20 Nov 2013, 09:21 AM
Hello Santhosh,


I was unable to reproduce the issue on my side and in our demos. Please send us a sample project, where it is reproducing, so we could inspect it locally and assist you further.

I am looking forward to hearing from you.

Regards,
Dimiter Madjarov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Juan
Top achievements
Rank 1
answered on 13 Dec 2013, 04:16 PM
HI, were you able to fix the double-firing? I am having the same issue.  I think the event is triggering on row and cell at the same time.

thanks,

Juan
0
Dimiter Madjarov
Telerik team
answered on 13 Dec 2013, 04:27 PM
Hello Juan,

The described issue was not reproduced. If you have a runnable example, where the strange behavior could be observed, please share it with us by attaching it to the post or via JS Bin, so we could inspect it and assist you.

I am looking forward to hearing from you.

Regards,
Dimiter Madjarov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Artsem
Top achievements
Rank 1
answered on 16 Dec 2013, 02:48 PM
Hello everyone, 

I have the same issue but only in  IE10, IE9, IE8.

thanks, 
Artsem
Tags
Grid
Asked by
santhosh
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Juan
Top achievements
Rank 1
Artsem
Top achievements
Rank 1
Share this question
or