【发布时间】:2016-10-21 19:58:04
【问题描述】:
如果我有一个包含超过 1 个值的剑道组合框,我想插入“-ALL-”作为 DataTextField,“9999”作为 DataValueField。目前,如果我只有一条记录,我使用 DataBound 事件对此进行测试,如果它 = 1,那么我会根据该值加载一个网格,但如果长度 > 1,那么我想添加 -All-。我不明白 Telik 所描述的插入。
@(Html.Kendo().ComboBox()
.Name("FAList")
.Placeholder("Select Fiscal Agency...")
.DataTextField("Text")
.DataValueField("Value")
.HtmlAttributes(new { style = "width:50%;" })
.Filter("startswith")
.AutoBind(true)
.MinLength(3)
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetUserAgencyList", "Entities");
})
.ServerFiltering(true);
})
.Events(e => e
.Change("onFAChange")
.DataBound("onFADataBound")
)
)
然后是绑定数据的函数
function onFADataBound(e) {
// the agency list dropdown
var combobox = $("#FAList").data("kendoComboBox");
// if there is only a single record then set that in the combobox and load the grid based on that
if (e.sender.dataSource.view().length == 1) {
e.sender.select(0);
var filter = this.value();
$.get('/City/CityGrid_Read', { id: filter }, function (data) {
var grid = $("#FollowUpGrid").data("kendoGrid");
grid.dataSource.read();
})
}
if (e.sender.dataSource.view().length > 1) {
}
}
【问题讨论】:
标签: kendo-ui kendo-asp.net-mvc