我已经使用了MVC剑道网格,并且我已经将下拉菜单绑定到了网格上。现在我必须通过使用下拉选择来让dropdownchange事件填充其他网格项。
columns.ForeignKey(c => c.CountryID, (SelectList)ViewBag.Countries).Title("Select Country");
$("#ddlTables").change(function () {
//You will get change event here
//Add debugger here and see
//Do your code here
});
columns.ForeignKey(c => c.CountryID, (SelectList)ViewBag.Countries,new {@id = "ddlCountry"}).Title("Select Country");
下面是代码,用你的代码替换这个,然后试着做你的东西,如果仍然面临问题,请告诉我。
你可以使用编辑器模板来做,如下所示,将栏目改为
columns.Bound(c => c.CountryID).Title("Country").EditorTemplateName("Countries").Width(300);
然后在里面创建一个局部视图 views/shared/EditorTemplates
有名字 Countries
如下
@using System.Collections
@(Html.Kendo().DropDownList()
.DataValueField("COUNTRYNAME")
.DataTextField("COUNTRYNAME")
.Name("CountryID")
.BindTo((IEnumerable)ViewBag.Countries)
.OptionLabel("Select Country")
.Filter(FilterType.Contains)
.Events(e =>
{
e.Change("CountryChange");
})
)
在这之后,你就可以写出如下的jquery了
<script>
function CountryChange()
{
//You will get change event here
}