In an MVC4 project, I have a kendo grid that fires an event when a row is selected.
<div id="datagrid"> @(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); ... }) .Events(e => e.Change("onChange")) <--------- here the event .DataSource(dataSource => dataSource .Ajax() .PageSize(15) .Read(read => read.Action("GetStretches", "MasterData")) ) ) </div>
So, when I select a row, the onChange function is onChange :
function onChange() { var code = this.dataItem(this.select()).StretchCode; $.get('@Url.Content("getStretchCode")', { "code": code }); }
In my controller, the code is retrieved, and some operations are performed with it.
public void getStretchCode(string code) { currentStretch.RoadComponentCode = code; ... }
It works great. The problem is that the event is fired every time I select a different row, but if I select a previously selected row, the event does not fire, and I cannot get the code for this row.
Any help?
source share