Kendo Grid Filterable DataSource Undefined

在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 用自已的数据

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容