Asp.net web api Kendo Dropdownlist服务器使用WebApi进行过滤

Asp.net web api Kendo Dropdownlist服务器使用WebApi进行过滤,asp.net-web-api,drop-down-menu,kendo-ui,Asp.net Web Api,Drop Down Menu,Kendo Ui,我正在尝试使用服务器过滤实现剑道下拉列表 我用这个例子作为起点 我的客户有以下代码 <div class="demo-section k-content"> <h4>Products</h4> <input id="products" style="width: 100%" /> </div> <script> $(document

我正在尝试使用服务器过滤实现剑道下拉列表 我用这个例子作为起点

我的客户有以下代码

 <div class="demo-section k-content">
        <h4>Products</h4>
        <input id="products" style="width: 100%" />
      </div>

      <script>
                $(document).ready(function() {
                    $("#products").kendoDropDownList({
                        filter: "startswith",
                        dataTextField: "Value",
                        dataValueField: "Key",
                        dataSource: {
                             pageSize               : 5,
                             serverPaging       : true,
                            serverFiltering : true,
                            serverSorting       : true,
                            transport: {
                                read: {
                                    dataType        : "json",
                                    type                : 'GET',
                                    url                 : "http://localhost:7340/DKAPI/FK/1004",

                                }
                            },
                            schema: {
                                data                    : "Data"

                            },
                        }
                    });
                });
                </script>
我的控制器在表单中

{
"Data": [22]
0:  {
"Key": 1
"Value": "JohnsdParker"
}-
1:  {
"Key": 2
"Value": "ClaireBennett"
}-
2:  {
"Key": 3
"Value": "Molly Jones"
}-
3:  {
"Key": 4
"Value": "PeterPetrelli"
}-
4:  {
"Key": 5
"Value": "DiarmuidO Reilly"
}-
5:  {
"Key": 10
"Value": "Mary Collins"
}-
6:  {
"Key": 17
"Value": "Paul O Neil"
}-
7:  {
"Key": 24
"Value": "LouiseO Herlihy"
}-
8:  {
"Key": 25
"Value": "NeilO Brien"
}-
9:  {
"Key": 26
"Value": "SeanFitzpatrick"
}-
10:  {
"Key": 27
"Value": "OliverSmith"
}-
11:  {
"Key": 28
"Value": "DG"
}-
12:  {
"Key": 29
"Value": "Josdfsfsdfss"
}-
13:  {
"Key": 30
"Value": null
}-
14:  {
"Key": 31
"Value": null
}-
15:  {
"Key": 32
"Value": "ougamouga"
}-
16:  {
"Key": 33
"Value": "hkkjhkhkhjk"
}-
17:  {
"Key": 34
"Value": ",khjkhkjlkjlkj"
}-
18:  {
"Key": 35
"Value": "trytrytutu"
}-
19:  {
"Key": 36
"Value": "sdfgsdgf"
}-
20:  {
"Key": 37
"Value": "testtest"
}-
21:  {
"Key": 38
"Value": "pablosdfsd"
}-
-
"Total": 22
"AggregateResults": null
"Errors": null
}
[HttpGet]
[Route("DKAPI/FK/{fkcolid}")]
public HttpResponseMessage Index([System.Web.Http.ModelBinding.ModelBinder(typeof(WebApiDataSourceRequestModelBinder))]DataSourceRequest request, int fkcolid)
{
    Dictionary<int, string> FKDict = _fkService.DDLBFKCol(fkcolid);

    if (FKDict == null)
        return Request.CreateResponse(HttpStatusCode.NotFound, "The Requested Resouce was not Fount");
    else
        return Request.CreateResponse(HttpStatusCode.OK, FKDict.ToDataSourceResult(request));
}
[HttpGet]
[路线(“DKAPI/FK/{fkcolid}”)]
公共HttpResponseMessage索引([System.Web.Http.ModelBinding.ModelBinder(typeof(WebApiDataSourceRequestModelBinder))]DataSourceRequest,int-fkcolid)
{
Dictionary FKDict=fkufkservice.DDLBFKCol(fkcolid);
如果(FKDECT==null)
return Request.CreateResponse(HttpStatusCode.NotFound,“请求的资源不存在”);
其他的
return Request.CreateResponse(HttpStatusCode.OK,FKDict.ToDataSourceResult(Request));
}
我的问题如下 最初加载DropDownList时,将加载前5个结果。当用户键入名称时,控制器上请求的Filters属性保持为Null。 我想我的控制器少了一些东西,但我不知道是什么。
该控制器是一个Web Api控制器

我终于用这个解决了这个问题 剑道文档似乎很差。。。 所以我最后的客户端代码是这样的

<script>
                    $(document).ready(function() {
                        $("#products").kendoDropDownList({
                            filter: "startswith",
                            dataTextField: "Value",
                            dataValueField: "Key",
                            dataSource: {
                            type: "aspnetmvc-ajax",
                                serverFiltering : true,
                                transport: {
                                    read: {
                                        dataType        : "json",
                                        type                : 'GET',
                                        url                 : "http://localhost:7340/DKAPI/FK/1004",
                                        crossOrigin : true

                                    }
                                },
                                schema: {
                                    data                    : "Data",
                                    total                   :"Total"        

                                },
                            }
                        });
                    });
                    </script>

$(文档).ready(函数(){
$(“#产品”)。kendoDropDownList({
过滤器:“startswith”,
dataTextField:“值”,
dataValueField:“密钥”,
数据源:{
键入:“aspnetmvc ajax”,
是的,
运输:{
阅读:{
数据类型:“json”,
键入:“GET”,
url:“http://localhost:7340/DKAPI/FK/1004",
交叉起源:对
}
},
模式:{
数据:“数据”,
总计:“总计”
},
}
});
});
我缺少数据源上的类型:“aspnetmvcajax”。除此之外,我认为DropDownList上的服务器过滤和分页不受支持,所以我删除了它们
希望它有助于…

其他信息。当我在chrome上调试示例()时,我可以看到以下查询字符串参数$callback:jquery19120066861202940345_1456918293601$inlinecount:allpages$format:json$filter:startswith(tolower(ProductName),'cha'),但当我在我的页面上调试时,我将其视为查询字符串参数take:5 skip:0 page:1 pageSize:5 filter[filters][0][value]:过滤器[filters][0][field]:文本过滤器[filters][0][operator]:启动过滤器[filters][0][ignoreCase]:真过滤器[logic]:和