简体   繁体   中英

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.

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

        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM