Kendo Grid 对日历的“dt”字段“等于”具有默认过滤器。对于“名称”字段,它具有默认过滤器“等于”,但我想将“包含”移动到选项列表的第一个位置并使其成为字符串的默认值。如何实现?
public class MyClass
{
public DateTime dt { get; set; }
public string name { get; set; }
}
@(Html.Kendo()
.Grid<MyClass>()
.Name("grid")
.DataSource(data =>
data.Ajax()
.ServerOperation(false)
.Read(read =>
read.Action("MyAction", "MyController"))
)
.Columns(cols =>
{
cols.Bound(x => x.dt).Title("Date").Width(150);
cols.Bound(x => x.name).Title("Name").Width(250);
})
.Filterable()
.Sortable())
最佳答案
看看Filter menu customization演示。看来您会按照以下方式做一些事情:
@(Html.Kendo()
.Grid<MyClass>()
.Name("grid")
.DataSource(data =>
data.Ajax()
.ServerOperation(false)
.Read(read =>
read.Action("MyAction", "MyController"))
)
.Columns(cols =>
{
cols.Bound(x => x.dt).Title("Date").Width(150);
cols.Bound(x => x.name).Title("Name").Width(250);
})
.Filterable(filterable => filterable
.Extra(false)
.Operators(ops => ops
.ForString(str => str.Clear()
.Contains("Contains")
.StartsWith("Starts with")
// any other filters you want in there
)))
.Sortable())
如果我正确解释它,
str.Clear()
清除存在的过滤器,因此您将从那里构建自己的过滤器。因此,如果您认为客户不需要或不想要 .EndsWith
过滤器,例如,您不会在此处包含它。
关于kendo-ui - 剑道网格MVC : default filter for string fields is set to "is equal to",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17487534/