This is a migrated thread and some comments may be shown as answers.

filtering a data-source throws error: no method 'toLowerCase'

2 Answers 307 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Dean
Top achievements
Rank 1
Dean asked on 19 Mar 2013, 01:38 AM
I'm trying to filter a data-source but I get the error described below. I did some research and found that it can normally be resolved by providing a schema.model that sets the offending property type to a number and this should tell kendoUI not to use toLowerCase() on it. Despite making this change, as you will see in the example, I still get the error. I'd appreciate some help.

Error message: Uncaught TypeError: Object 1 has no method 'toLowerCase'

Example: http://jsbin.com/ocehiq/1/edit - the error occurs when you change the selected category, which is supposed to filter the list of products

2 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 19 Mar 2013, 01:53 PM
Hello Dean,

The value that is being passed to filter descriptor must of correct type, not only the model filed definition. What this is means is that the value must be cast to number in the following line:

myViewModel.productSource.filter({
 field: "Category_id",
 operator: "eq",
 value: ~~$(e.currentTarget).val()
});
 

Here is an updated fiddle: http://jsbin.com/ocehiq/4/edit

All the best,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Dean
Top achievements
Rank 1
answered on 19 Mar 2013, 11:37 PM
Thanks! The more I learn about Kendo UI Mobile, the more I learn about JavaScript in general too.
Tags
General Discussions
Asked by
Dean
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Dean
Top achievements
Rank 1
Share this question
or