【发布时间】:2014-03-01 01:20:30
【问题描述】:
我有一个 Kendo 下拉列表控件,我在页面初始加载时通过 SelectList 填充该控件。
@(Html.Kendo().DropDownListFor(m => m.AssociatedWithType)
.Events(x => x.Select("CR.TodoAddEditDialog.AssociatedWithSelected"))
.Value(ViewBag.AssociatedWithTypesId)
.BindTo(ViewBag.AssociatedWithTypesSelectList)
)
@(Html.Kendo().DropDownListFor(m => m.AssociatedWithId)
.BindTo(ViewBag.AssociatedWithIdsSelectList)
)
这一切都很好,但是当第一个下拉列表更改值时,我需要重新加载数据。我有以下 javascript:
AssociatedWithSelected: function(e) {
var dataItem = this.dataItem(e.item.index());
var associatedWithIdsDropDown = $("#todoAddEditDialogForm #AssociatedWithId").data("kendoDropDownList");
var url = settings.getAssociatedWithIdsUrl + "?associatedWithType=" + dataItem.Text;
associatedWithIdsDropDown.dataSource.read({
url: url
});
}
但是,什么都没有被调用。
我怀疑这是因为我从未在下拉列表中定义数据源,但我不知道如何在 MVC 部分定义一个而不使用它来初始填充列表。
有什么想法吗?
【问题讨论】:
-
您的选择事件正在寻找一个名为 CR.TodoAddEditDialoge.AssociatedWithSelected 的函数,而不是您的 JS 函数只是 AssociatedWithSelected
-
@CSharper,是的,为简洁起见,我没有包含命名空间代码。
标签: ajax asp.net-mvc-4 kendo-ui dropdownlistfor