【问题标题】:Error filtering Kendo UI grid过滤 Kendo UI 网格时出错
【发布时间】:2014-10-15 09:12:10
【问题描述】:

我正在尝试以编程方式过滤 Kendo UI 网格,但出现此错误:

TypeError: "".toLowerCase 不是函数

下面是我用来过滤网格的代码:

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

我指的是下面的链接并以相同的方式做,但不是在我这边工作。

http://jsfiddle.net/valchev/MG89G/

请提出建议。

【问题讨论】:

  • 您确定错误出在这段代码中吗?我在这里看不到与您的类型错误有关的任何内容
  • 是的,我确定这个功能是用来过滤记录的。
  • 你能显示调用该函数的代码吗

标签: javascript jquery kendo-ui


【解决方案1】:

不知何故,我对代码进行了更改,它解决了这个问题。我所做的是我用 value: parseFloat(amount) 替换了代码行: value: amount 并且效果很好。

【讨论】:

    【解决方案2】:

    我也有这个问题。将数字列添加到 dataSource 架构并没有解决它。

    在列定义中添加type: 'number' 也没有解决问题。

    最终对我有用的是parseInt() 过滤器文本并将我的运算符从“包含”更改为“eq”。

    【讨论】:

      【解决方案3】:

      剑道似乎喜欢施法的领域。我必须补充:

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

      【讨论】:

        【解决方案4】:

        这对我也有用,谢谢 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);
                    }
        
                }
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2018-01-22
          • 1970-01-01
          • 2019-07-26
          相关资源
          最近更新 更多