如何强制Kendo Grid在列上使用数字过滤器 [英] How can I force Kendo Grid to use a numeric filter on a column
本文介绍了如何强制Kendo Grid在列上使用数字过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用以下代码,即使类型为int
,Kendo Grid仍将字符串过滤器接口用于t.Files.Count
.如何强制网格改为使用数字过滤器用户界面?
Using the following code, Kendo Grid uses the string filter interface for t.Files.Count
even though the type is an int
. How can I force the grid to use the numeric filter UI instead?
@(Html.Kendo().Grid<GJW_Site.Web.Models.TargetsModel>()
.Name("grid")
.Columns(columns => {
columns.Bound(t => t.ID).Width(80);
columns.Bound(t => t.OrbitalPeriod);
columns.Bound(t => t.Files.Count);
})
.Sortable()
.Filterable()
.DataSource(dataSource => dataSource.Ajax()
.PageSize(20)
.Read(read => read.Action("Targets_Read", "Targets"))
)
.Resizable(o => o.Columns(true))
.ColumnMenu()
)
产生用于字符串的过滤器菜单:
Produces a filter menu for strings:
我正在使用Kendo.MVC 2013.1.514.340
I am using Kendo.MVC 2013.1.514.340
推荐答案
解决方案是指定模型中的值是int
-如此更改DataSource
方法:
The solution is to specify that the value is an int
in the model - change the DataSource
method as so:
.DataSource(dataSource => dataSource.Ajax()
.PageSize(20)
.Read(read => read.Action("Targets_Read", "Targets"))
.Model(m => {
m.Field<int>(t => t.Files.Count);
})
)
这篇关于如何强制Kendo Grid在列上使用数字过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文