JSHunjan
JSHunjan

Reputation: 397

Error filtering Kendo UI grid

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.net/valchev/MG89G/

Please suggest.

Upvotes: 4

Views: 5202

Answers (4)

Romeo Acharya
Romeo Acharya

Reputation: 11

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

        }

Upvotes: 0

Ebbs
Ebbs

Reputation: 1050

Kendo seems to like fields to be cast. I had to add:

template: function (dataItem) {
    return kendo.toString(dataItem.FriendlyStatus);
}

Upvotes: 0

Grid Trekkor
Grid Trekkor

Reputation: 1473

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.'

Upvotes: 2

JSHunjan
JSHunjan

Reputation: 397

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.

Upvotes: 2

Related Questions