0

我已经在 labourmeansstatusenum 列上实现了一个自定义 ui 过滤器。但是该函数没有被调用,因此过滤器没有自定义值。任何想法我做错了什么?

       @(Html.Kendo().Grid<Presentation.Mvc.Models.LabourMeans.LabourMeansViewModel>()
.Name("grid")
.Columns(columns =>
{
    /**/

    columns.Bound(s => s.LabourMeansStatusEnum)
        .ClientTemplate("# if (LabourMeansStatusEnum  == 0){#" +
                                                               "<div id='outofservice'><span class='label label-info arrowed-right arrowed-in'>" + @Label.OutOfService() + "</span></div>" +
                                                               "#}else if (LabourMeansStatusEnum  == 1){#" +
                                                               "<div id='intreatment'><span class='label label-info arrowed-right arrowed-in '>" + @Label.InTreatment() + "</span></div>" +
                                                               "#}else if (LabourMeansStatusEnum  == 2){#" +
                                                               "<div id='inservice'><span class='label label-info arrowed-right arrowed-in '>" + @Label.InService() + "</span></div>" +
                                                               "#}#"
                                                               )
                                                               .Title("Status")
                                                               .Filterable(filterable => filterable.UI("labourMeansStatusFilter"));


            .Filterable(filterable => filterable
            .Extra(false)
            .Operators(operators => operators
            .ForString(str => str.Clear()
            .IsEqualTo(@Label.IsEqualTo())
            .IsNotEqualTo(@Label.IsNotEqualTo())
            ))
            )


            .Resizable(resize => resize.Columns(true))
            .Pageable()
            .Scrollable()
            .Sortable()
            .Reorderable(reorder => reorder.Columns(true))
            .DataSource(dataSource => dataSource
                .Ajax()
                .Sort(sort => sort.Add("Id").Ascending())
                .PageSize(10)
                .Model(model => model.Id(s => s.LabourMeans.LabourMeans.Id))
                .Read(read => read.Action("LabourMeans_Read", "LabourMeans"))
               )

        )

js过滤功能:

function labourMeansStatusFilter(element) {
    alert("test");
    element.kendoDropDownList({
        dataSource: [
            { Name: "Parent1", Id: 1 },
            { Name: "Parent2", Id: 2 }
        ],
        dataTextField: "Name",
        dataValueField: "Id"
    });
    alert("test5");
}
4

1 回答 1

0

根据我的发现,自定义过滤器方法永远不会被枚举类型调用。我不确定这是否是 Kendo 中的错误,还是设计使然,但也许您可以通过公开包装器属性以从/转换为枚举的字符串表示来解决它?

于 2014-03-04T21:49:14.897 回答