简体   繁体   中英

Filtering on Kendo UI Grid when Locally Bound Data is an integer

I have a Kendo UI Web Grid bound to a local Javascript Array. Each item in the JS Array has a field userType which is an integer. I used the column.values configuration to define Textual representations of the values. However, when I try to filter on the column, there is a TypeError: Object 1 has no method 'toLowerCase' . I guess it is failing to treat the column as an integer and trying to convert it into a string.

See this fiddle for example: http://jsfiddle.net/t97pY/

Filtering on the 'userType' column causes the issue.

Is this a bug in the Kendo Grid? If so, how do I get it reported and resolved?

The grid always assumes the data type is string. The solution is to add a schema definition to your data source.

dataSource: {
        data: [{
            name: "Jane Doe",
            age: 30,
            userType: 0
        }, {
            name: "John Doe",
            age: 33,
            userType: 1
        }],
        schema: {
            model: {
                fields: {
                    age: { type: 'number' },
                    userType: { type: 'number' }
                }
            }
        }
    }

I modified your fiddle: http://jsfiddle.net/t97pY/4/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM