admin管理员组文章数量:1403358
I am trying to filter Kendo UI grid programatically but getting this error:
TypeError: "".toLowerCase is not a function
Below is the code which I am using to filter grid:
function filterSavedTransactions(checkboxstate,grid,field1,field2,amount)
{
if (!parseFloat(amount))
amount = 0;
if (checkboxstate) {
var ds = $('#' + grid.attr('id')).data("kendoGrid").dataSource;
ds.filter([{
"logic":"and",
filters: [
{
field: field2,
operator: "gt",
value: amount
},
{
field: field1,
operator: "neq",
value: checkboxstate
}]
}]);
}
else {
$('#' + grid.attr('id')).data("kendoGrid").dataSource.filter({});
}
}
I am trying to filter Kendo UI grid programatically but getting this error:
TypeError: "".toLowerCase is not a function
Below is the code which I am using to filter grid:
function filterSavedTransactions(checkboxstate,grid,field1,field2,amount)
{
if (!parseFloat(amount))
amount = 0;
if (checkboxstate) {
var ds = $('#' + grid.attr('id')).data("kendoGrid").dataSource;
ds.filter([{
"logic":"and",
filters: [
{
field: field2,
operator: "gt",
value: amount
},
{
field: field1,
operator: "neq",
value: checkboxstate
}]
}]);
}
else {
$('#' + grid.attr('id')).data("kendoGrid").dataSource.filter({});
}
}
I am referring to below link and doing in the same way but not working on my side.
http://jsfiddle/valchev/MG89G/
Please suggest.
Share Improve this question edited Oct 15, 2014 at 9:18 JSHunjan asked Oct 15, 2014 at 9:12 JSHunjanJSHunjan 3971 gold badge5 silver badges18 bronze badges 3- 1 Are you sure the error is in this piece of code? I cannot see anything relating to your type error here – Bobby Commented Oct 15, 2014 at 9:32
- Yes, I am sure as this function is used to filter records. – JSHunjan Commented Oct 15, 2014 at 10:20
- Can you show the piece of code where that function is called – Bobby Commented Oct 15, 2014 at 10:49
4 Answers
Reset to default 2Somehow, I made changes in code and it fixed the issue. What I did is that I replaced line of code : value: amount with value: parseFloat(amount) and it worked fine.
I had this issue too. Adding the numeric columns to the dataSource schema didn't fix it.
Adding type: 'number'
to the column definition didn't fix it either.
What finally worked for me was to parseInt()
the filter text and change my operator from 'contains' to 'eq.'
Kendo seems to like fields to be cast. I had to add:
template: function (dataItem) {
return kendo.toString(dataItem.FriendlyStatus);
}
This worked from me too Thanks Ebbs
columns: [
{
field: "MyFieldNameWhichisInteger", title: "My Field Name", width: "200px",
filterable: {
extra: false,
operators: {
string: {
startswith: "Starts with",
eq: "Is equal to",
neq: "Is not equal to"
}
},
cell: {
operator: "eq",
suggestionOperator: "eq"
}
},
template: function (dataItem) {
return kendo.toString(dataItem.MyFieldNameWhichisInteger);
}
}
本文标签: javascriptError filtering Kendo UI gridStack Overflow
版权声明:本文标题:javascript - Error filtering Kendo UI grid - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744412605a2605032.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论