自定义列过滤器kendo ui网格

时间:2013-10-04 08:35:05

标签: kendo-ui kendo-grid

我已在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");
}

1 个答案:

答案 0 :(得分:0)

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