I'm using a grid client-side data and a shared dataSource.
The client-side filtering produces an error stated in the title in some columns, other columns seem to work fine.
It seems to occur in columns with numeric data.
What could be the cause of this?
The client-side filtering produces an error stated in the title in some columns, other columns seem to work fine.
It seems to occur in columns with numeric data.
What could be the cause of this?
7 Answers, 1 is accepted
0
Hello Roland,
This error is raised when you attempt to filter numeric value as a string. For example executing the following script in browser console will result is the same error:
In order to avoid that you must define DataSource schema and describe that those fields are numeric. For example see the DataSource.schema.model definition in this demo: http://demos.kendoui.com/web/grid/local-data.html
This article explains in details the data source configuration: http://docs.kendoui.com/api/framework/datasource#schemamodel-objectkendodatamodel
Regards,
Nikolay Rusev
the Telerik team
This error is raised when you attempt to filter numeric value as a string. For example executing the following script in browser console will result is the same error:
var
foo = 1;
foo.toLowerCase();
// <-- will throw an error
In order to avoid that you must define DataSource schema and describe that those fields are numeric. For example see the DataSource.schema.model definition in this demo: http://demos.kendoui.com/web/grid/local-data.html
This article explains in details the data source configuration: http://docs.kendoui.com/api/framework/datasource#schemamodel-objectkendodatamodel
Regards,
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
0
Hello Craig,
You are observing same error for same reasons. Filtering on numbers as strings is not allowed.
The default filter for the AutoComplete widget is "startsWith". If you still need auto complete in filter menu for that column you should configured it properly.
Here is an example of possible configuration that will work:
Regards,
Nikolay Rusev
the Telerik team
You are observing same error for same reasons. Filtering on numbers as strings is not allowed.
The default filter for the AutoComplete widget is "startsWith". If you still need auto complete in filter menu for that column you should configured it properly.
Here is an example of possible configuration that will work:
function
documentIdFilter(element) {
element.kendoAutoComplete({
dataSource: {
data: documentIds
},
ignoreCase:
false
,
//<--ignore the casing will stop applying .toLowerCase()
filter:
"gte"
//<-- filter operator compliant with `number` type
});
}
Regards,
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
Craig
Top achievements
Rank 1
answered on 07 Feb 2013, 05:40 PM
Ok that makes sense.
I was trying to follow the example from:
http://demos.kendoui.com/web/grid/filter-menu-customization.html
It didn't even occur to me that the DropDownList had a default filter applied. I guess I was "assuming" too much. Thanks for the very clear answer to the problem. I hope your answer will be able to assist many other people. I have seen very similar questions about this on StackOverFlow.
Thanks again I will spread the knowledge!
I was trying to follow the example from:
http://demos.kendoui.com/web/grid/filter-menu-customization.html
It didn't even occur to me that the DropDownList had a default filter applied. I guess I was "assuming" too much. Thanks for the very clear answer to the problem. I hope your answer will be able to assist many other people. I have seen very similar questions about this on StackOverFlow.
Thanks again I will spread the knowledge!
0
jwize
Top achievements
Rank 1
answered on 30 Aug 2013, 08:15 AM
It should be also worth noting that if you are using MVC extensions. You can accomplish the same thing by either changing your number to a string in the schema as follows:
or more logically use Number function if your javascript is returning a string.
This was pretty annoying for me to figure out but now all is groovy!
d.Ajax().ServerOperation(
false
)
.Model(m =>
{
m.Id(p => p.Id);
m.Field(
"ResourceTypeId"
,
typeof
(System.String));
})
var
number = Number($(item).find(
"input"
).val());
var filter =
{
field:
"ResourceTypeId"
,
operator:
"eq"
,
value: number
};
0
Darren
Top achievements
Rank 1
answered on 01 Apr 2015, 02:43 PM
My filter looks like this:
{
"logic": "and",
"filters": [
{
"field": "iDealNumber",
"operator": "eq",
"value": 307304
},
{
"field": "dtTradeTime",
"operator": "gt",
"value": "2015-03-29T00:00:00.000Z"
}
]
}
And I get: Uncaught TypeError: undefined is not a function
However this works:
{
"logic": "and",
"filters": [
{
"field": "iDealNumber",
"operator": "eq",
"value": 307304
},
]
}
So I suspect it has something to do with the date being a value.
Not sure how to handle it, any ideas?
{
"logic": "and",
"filters": [
{
"field": "iDealNumber",
"operator": "eq",
"value": 307304
},
{
"field": "dtTradeTime",
"operator": "gt",
"value": "2015-03-29T00:00:00.000Z"
}
]
}
And I get: Uncaught TypeError: undefined is not a function
However this works:
{
"logic": "and",
"filters": [
{
"field": "iDealNumber",
"operator": "eq",
"value": 307304
},
]
}
So I suspect it has something to do with the date being a value.
Not sure how to handle it, any ideas?
0
Hello Darren,
I'm not completely sure for your scenario. However based on the information I assume that the `dtTradeTime` is defined as Date in the DataSource. In this case the value for the filter expression should match the type of the field.
Regards,
Nikolay Rusev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!