最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Error filtering Kendo UI grid - Stack Overflow

programmeradmin2浏览0评论

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
Add a ment  | 

4 Answers 4

Reset to default 2

Somehow, 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);
            }

        }
发布评论

评论列表(0)

  1. 暂无评论