简体   繁体   English

在数字数组上使用ASP.NET MVC中的Kendo UI ComboBox进行过滤

[英]Filtering with the Kendo UI ComboBox in the ASP.NET MVC on array of numbers

I have a problem to use filtering in the Kendo UI ComboBox with the list of integers. 我在Kendo UI ComboBox中使用带有整数列表的过滤时遇到问题。 I use list of integers as a DataSource , Filter of type StartsWith and ServerFiltering(false) . 我将整数列表用作数据源StartsWithServerFiltering(false)类型的Filter。

@(Html.Kendo().ComboBox().Placeholder("Jahr")
      .IgnoreCase(true)
      .Name("planungsZeiten")
      .Filter(FilterType.StartsWith)
      .DataSource(source => source.Read(read => read.Action("GetPlanungsZeiten", "Reweco"))
                                  .ServerFiltering(false)))

public JsonResult GetPlanungsZeiten()
{
    using (var repo = new ANECON_PDATAEntities())
    {
        return Json(repo.PlanungsZeiten.Select(j => j.Jahr).OrderByDescending(j => j).ToList(), JsonRequestBehavior.AllowGet);
    }
}

As I type in the ComboBox , JavaScript exception is thrown: 当我在ComboBox中键入内容时,会引发JavaScript异常:

Object doesn't support property or method 'toLowerCase' 对象不支持属性或方法“ toLowerCase”

在此处输入图片说明

在此处输入图片说明

This happens because the type number don't support the method toLower . 发生这种情况是因为类型编号不支持toLower方法。

The version I using is 2013.1.514 but the same behavior is on latest version 2014 Q1 SP1 (2014.1.416) as you can see here: http://jsfiddle.net/akalcik/Fv8S5/1/ 我使用的版本是2013.1.514,但最新版本2014 Q1 SP1(2014.1.416)的行为相同,如此处所示: http : //jsfiddle.net/akalcik/Fv8S5/1/

I already tried to set .IgnoreCase(true) but it make no difference. 我已经尝试设置.IgnoreCase(true),但没有区别。 Do I something wrong or is it the bug? 我有什么问题还是错误?

Startwith is not a valid filter for integer type. Startwith不是有效的整数类型过滤器。 You should either use integer filters (equal, greater than, etc.), or change the type of your underlying source integer field to string to apply string filters. 您应该使用整数过滤器(等于,大于等),或者将基础源整数字段的类型更改为string以应用字符串过滤器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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