Set default filter for Kendo UI Grid

后端 未结 5 1654
我寻月下人不归
我寻月下人不归 2020-12-17 21:18

I have a Kendo UI grid that is rendered with javaScript. I want the string columns to have a single option (\"Contains\") and without the second filter. So far so good, I wr

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-17 22:09

    I had the same problem and I got it, that it needs the .Clear() option!

    I am building my Grid with the MVC Wrapper in Razor:

    @(Html.Kendo().Grid()
        .Name("locationGrid")
        // other bits of configuration here
        .ColumnMenu()
        .Filterable(f => f.Operators(o => o.ForString(s => s
            .Clear()
            .Contains("Contains")
            .DoesNotContain("Does not contain")
            .EndsWith("Ends with")
        )))
        // other bits of configuration here
    )
    

    Summary:

    1. .Clear() is needed!
    2. Sorting is necessary! Put .Contains() first after .Clear() then the default is Contains!

    Additional Info: I am using Kendo UI 2013.1.514

提交回复
热议问题