【问题标题】:How to change the default filter operator in kendo ui grid mvc如何更改 kendo ui grid mvc 中的默认过滤器运算符
【发布时间】:2013-09-30 14:46:02
【问题描述】:

我已经设法使用以下方法更改了 Kendo Grid 的默认过滤顺序:

.Filterable(filterable => filterable
                        .Extra(true)
                        .Operators(ops => 
                            ops.ForString(str => str.Clear()
                                                    .Contains("Contains")
                                                    .StartsWith("Starts with")
                                                    .EndsWith("Ends with")
                                                    .IsEqualTo("Is equal to"))
                        ))

有什么方法可以将默认运算符更改为 OR?

【问题讨论】:

    标签: asp.net-mvc grid kendo-ui


    【解决方案1】:

    这可以通过filterMenuInit 事件来完成:

     /* grid configuration snip */
    .Events(e => e.FilterMenuInit("filterMenuInit"))
     /* grid configuration snip */
    
     <script>
     function filterMenuInit(e) {
          e.container
             .find("select.k-filter-and")
             .data("kendoDropDownList")
             .value("or");
     }
     </script>
    

    这是一个现场演示:http://jsbin.com/etItEpi/1/edit

    【讨论】:

    • 不幸的是,此解决方案仅部分有效,并导致非常令人不安的用户体验:重新排序列后,操作员重置回“与”。要重现这一点:1)将示例中的网格/列配置为可排序,2)运行,3)单击过滤器并注意运算符是“或”。 4) 通过单击其标题对列重新排序 5) 单击过滤器,并注意运算符已重置为其默认值:'And'。
    • @g.pickardou 或直接按清除按钮。
    【解决方案2】:

    您也可以根据您的网格定义 (MVC) 逐列执行此操作:

    cols.Bound(m => m.xxx).Filterable(f=> f.Cell(cell => cell.Operator("or")));
    

    【讨论】:

    • 这似乎不起作用。没有编译错误,没有运行时错误,但是默认的 And 操作仍然存在
    • 这是GridFilterMode.Row过滤模式
    猜你喜欢
    • 2020-07-04
    • 2012-12-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多