Skip to content Skip to sidebar Skip to footer

Kendo Grid Change Event Fires Only Once Per Row Selection

In a MVC4 project, I've got a kendo grid that fires an event when a row is selected.
@(Html.Kendo().Grid() .Name('d

Solution 1:

Add .Selectable() in your grid so it allow you select previously row.

@(Html.Kendo().Grid<SustIMS.Models.StretchModel>()
    .Name("datagrid_Stretches")
    .Columns(columns =>
    {
        columns.Bound(s => s.StretchCode).Title(ViewBag.lblCode).Width(80);
        columns.Bound(s => s.StretchMediumDescription).Title(ViewBag.lblDescription);
        ...
    })
 .Selectable(selectable => selectable
            .Type(GridSelectionType.Row)  <--------- Add This
            )
    .Events(e => e.Change("onChange"))    
    .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(15)
        .Read(read => read.Action("GetStretches", "MasterData"))
    )
)

Script

function onChange() {
    var code = this.dataItem(this.select()).StretchCode;
    $.post('@Url.Content("getStretchCode")',
        { "code": code });
}

Solution 2:

you should add Selectable() before add event like this

 .Selectable(selectable => selectable
            .Mode(GridSelectionMode.Multiple)
            .Type(GridSelectionType.Cell))
.Events(e => e.Change("onChange"))

Post a Comment for "Kendo Grid Change Event Fires Only Once Per Row Selection"