我按照Elsimer提供的解决方案:Kendo Grid MVC: default filter for string fields is set to "is equal to"
我收到了将Contains移动到列表顶部的请求,因此它是默认过滤器。所以我设置Filterable()如下:
.Filterable(filterable => filterable
.Extra(false)
.Operators(ops => ops
.ForString(str => str.Clear()
.Contains("Contains")
.IsEqualTo("Is equal to")
.IsNotEqualTo("Is not equal to")
.StartsWith("Starts with")
.EndsWith("Ends with")
.DoesNotContain("Does not contain")
.IsNull("Is null")
.IsNotNull("Is not null")
.IsEmpty("Is empty")
.IsNotEmpty("Is not empty")
)))
不幸的是,这对订单或默认过滤器没有任何作用。但是,如果我只删除一个选项以使筛选器列表不完整(可以是任何选项,例如IsEmpty),那么所有内容都会以正确的顺序显示。
例如,随着IsEmpty的消失:
.Filterable(filterable => filterable
.Extra(false)
.Operators(ops => ops
.ForString(str => str.Clear()
.Contains("Contains")
.IsEqualTo("Is equal to")
.IsNotEqualTo("Is not equal to")
.StartsWith("Starts with")
.EndsWith("Ends with")
.DoesNotContain("Does not contain")
.IsNull("Is null")
.IsNotNull("Is not null")
.IsNotEmpty("Is not empty")
)))
欢迎来到剑道迷人的世界! :D我在2016年10月遇到了同样的问题。这是支持回复的内容:
这是因为,当所有操作符都存在时,使用默认顺序。这就是网格过滤器序列化的实现方式。
您唯一合理的选择是跳过至少一个过滤器运算符。