在MVC4项目,我有一个剑道网格时选择的行触发一个事件。
<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's the event
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(15)
.Read(read => read.Action("GetStretches", "MasterData"))
)
)
</div>
所以,当我选择一排, onChange
函数被调用:
function onChange() {
var code = this.dataItem(this.select()).StretchCode;
$.get('@Url.Content("getStretchCode")',
{ "code": code });
}
在我的控制器,代码检索和一些操作用它做。
public void getStretchCode(string code)
{
currentStretch.RoadComponentCode = code;
...
}
这工作得很好。 问题是,该事件被解雇每次我选择一个不同的行,但如果我选择之前选择一排,没有触发事件时,我不能让该行的代码。
任何帮助吗?