在kendo Grid中肯定义
Html.Kendo().Grid<...>()
...
.Columns(columns =>
{
...
columns.Bound(e => e.StatusTypeID).Filterable(ftb => ftb.Multi(true).Cell(cell=>cell.ShowOperators(false).Template("customDropDownList")
.DataSource(d =>d.Custom())
.BindTo(new[]{
new { StatusTypeID = "0", Text = "OFF" },
new { StatusTypeID = "1", Text = "ON" },
new { StatusTypeID = "3", Text = "IDLE" },
})).DataSource(d =>d.Custom())
.BindTo(new[]{
new { StatusTypeID = "0", Text = "OFF" },
new { StatusTypeID = "1", Text = "ON" },
new { StatusTypeID = "3", Text = "IDLE" },
}))
.ClientTemplateId("statusTypeIDTemplate")
.Width(120);
...
})
.Pageable()
.Sortable()
.Scrollable()
.Filterable(ftb => ftb.Mode(GridFilterMode.Row))
.HtmlAttributes(new { style = "height:550px;" })
.Pageable(pager => pager.AlwaysVisible(true).PageSizes(new int[] { 5, 10, 20, 50, 100 }))
.DataSource(dataSource => dataSource
.WebApi()
.PageSize(20)
.Read(read => read.Action("Action", "Controller"));
<script>
function customDropDownList(args) {
console.log(args)
args.element.kendoDropDownList({
dataSource: @(Json.Serialize(new[] {
new { StatusTypeID = "0", Text = "OFF" },
new { StatusTypeID = "1", Text = "ON" },
new { StatusTypeID = "3", Text = "IDLE" },
})),
dataTextField: "Text",
dataValueField: "StatusTypeID",
valuePrimitive: true
});
}
</script>
这两种情况下 args.dataSrouce 都是undefined,不知道是故意的还是BUG,从页面源文件中看到论是filterable,还是cell上都有dataSrouce
解决方案,不钻牛角尖,filtable 用自已的数据