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:
I am using Kendo.MVC 2013.1.514.340
I have faced similar issue when the filter are coming for data type string while my data type is "number", this happens if there is a discrepancy in declaring the schema, make sure the field declared in schema are correct i.e. have same name as the data you are getting/supplying to grid.
You can also use this solution:
Kendo will be able to select a right filter type for each column, but you have to use properties instead of fields in
TargetsModel
.For example, use this:
instead of this:
If for some reason you are unable to do this, the
.Model()
approach is probably the best way.The solution is to specify that the value is an
int
in the model - change theDataSource
method as so: