我正在使用 KendoUI,我想研究一下它是如何进行过滤的。我遇到了下面的代码片段:
http://demos.telerik.com/aspnet-mvc/grid/filter-row
我编写了如下代码:
<div id="clientsDb">
@(Html.Kendo().Grid<Prometheus.Core.Domain.Employee>()
.Name("employeeGrid")
.Columns(columns =>
{
columns.Bound(c => c.Id).Width(140).Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")));
columns.Bound(c => c.FirstName).Width(190).Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")));
columns.Bound(c => c.LastName);
})
.HtmlAttributes(new {style = "height: 380px;"})
.Scrollable()
.Groupable()
.Sortable()
.Pageable(pageable => pageable
.Refresh(true)
.PageSizes(true)
.ButtonCount(5))
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("ReadEmployee", "EmployeeGrid"))))
我没有看到任何错误,但在网格中的任何位置都没有看到启用任何搜索过滤器。
但是,以下代码对我来说工作正常,它在网格级别添加过滤器而不是在列级别添加它:
<div id="clientsDb">
@(Html.Kendo().Grid<Prometheus.Core.Domain.Employee>()
.Name("employeeGrid")
.Columns(columns =>
{
columns.Bound(c => c.Id).Width(140).Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")));
columns.Bound(c => c.FirstName).Width(500).Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")));
columns.Bound(c => c.LastName);
})
.HtmlAttributes(new { style = "height: 380px;" })
.Scrollable()
.Groupable()
.Sortable()
.Selectable()
.Pageable(pageable => pageable
.Refresh(true)
.PageSizes(true)
.ButtonCount(5))
.Filterable(filterable => filterable
.Extra(true)
.Operators(operators => operators
.ForString(str => str.Clear()
.Contains("Contains")
.IsEqualTo("Exactly matches")
.StartsWith("Starts with")
.DoesNotContain("Does not contain")
.EndsWith("Ends with")
.IsNotEqualTo("Is not equal to")
))).DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("ReadEmployee", "EmployeeGrid"))))
</div>
我不确定这里有什么大区别,因为两者都使用几乎相同的可过滤属性。有任何想法吗?