如何强制 Kendo Grid 在列上使用数字过滤器 [英] How can I force Kendo Grid to use a numeric filter on a column

查看:22
本文介绍了如何强制 Kendo Grid 在列上使用数字过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用以下代码,Kendo Grid 对 t.Files.Count 使用字符串过滤器接口,即使类型是 int.如何强制网格改用数字过滤器 UI?

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆