Reputation: 249
Kendo ui grid I attached the change event on grid,but every time it alert twice when i click one row.
function onChange(arg) {
var selected = $.map(this.select(), function (item) {
return $(item).text();
});
alert(selected.join(", "));
}
the grid code
@(Html.Kendo().Grid<ETender.Mvc.Models.Region>()
.Name("country")
.Columns(columns =>
{
columns.Bound(r => r.ID);
columns.Bound(r => r.CNAME);
columns.Bound(r => r.ENAME);
})
.Sortable()
//.Scrollable(scrollable => scrollable.Virtual(false).Height(500))
.Selectable()
.Pageable()
.Reorderable(reorder => reorder.Columns(true))
.Resizable(resize => resize.Columns(true))
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(true)
.Events(ev => ev.Error("loadError"))
.Model(m =>
{
m.Id(p => p.ID);
m.Field(p => p.ID).Editable(false);
})
.Read(read => read.Action("GetRegionList", "Region")
.Data("function() { return { CountryID:'0',ProvinceID:'0',CityID:'0',RegionType: 'Country'}; }")
)
)
.Events(events => events.Change("onChange"))
)
Who have the solution.
Upvotes: 2
Views: 6235
Reputation: 1889
Basically this behavior is caused by using "alert" method for debugging purposes - please note that this is not recommended because it can lead to unexpected behavior when interacting with focusing elements. After replacing the "alert" method and with "debugger" command or "console.log()" function the change event will work as expected.
Upvotes: 2