在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 用自已的數(shù)據(jù)