【问题标题】:Kendo Grid Serverside Paging, Incorrect Parameter Map valuesKendo Grid 服务器端分页,参数映射值不正确
【发布时间】:2015-08-17 22:32:06
【问题描述】:

我正在尝试使用 Kendo 的 Dynamic Linq Helper 库。网格上的参数映射函数没有正确的参数发送到控制器。

parameterMap 选项有: {"take":10,"skip":0,"page":1,"pageSize":10}

但是按照例子,应该有take、skip、sort、filter,这些不在parameterMap函数中,也没有传给服务器。

我这里是按照例子来的

http://www.telerik.com/blogs/kendo-ui-open-sources-dynamic-linq-helpers

还看了其他例子,我的网格设置和其他的一样。

唯一的区别是,这是一个 Web API 单页应用程序,而不是 MVC。但是,这不会对 Grid 类传递给它的 parameterMap 函数的内容产生影响。

这是怎么回事?

$("#grid").kendoGrid({

dataSource: {
   transport: {
                read: {
                    url: "http://localhost/biahost/query/projectStatuses",
                    dataType: "application/json",
                    type: "POST",
                    contentType: "application/json; charset=utf-8"
                    //data:{}
                },
                parameterMap: function (options) {
                    debugger;
                     //options only contain    {"take":10,"skip":0,"page":1,"pageSize":10}
                    return kendo.stringify(options);
                }
            },
            schema: {
                data: "Data",
                total: "Total",
                model: {
                    fields: {
                        NAME: { type: "string" },
                        CODE: { type: "string" },
                        STATUS: { type: "string" },
                        COMMENTS: { type: "string" },
                        INSERTS: { type: "string" },
                        UPDATES: { type: "string" },
                        TOTAL_UPDATES: { type: "string" },
                        LAST_ACTION_DATE: { type: "string" }

                        //UnitId: { type: "string" },
                        //UnitName: { type: "string" }
                    }
                }
            },
            pageSize: 10,
            serverPaging: true,
            serverFiltering: true,
            serverSorting: true
        },
        filterable: true,
        sortable: true,
        pageable: true,
        columns: projectStatusColumns
    });


var projectStatusColumns = [
           {
               field: 'NAME',
               label: 'Res name',
               hidden: true,
           },
           {
               field: 'CODE',
               label: 'Code'
           },
           {
               field: 'STATUS',
               label: 'Status'
           },
           {
               field: 'COMMENTS',
               label: 'Comments'
           }
           ,
           {
               field: 'INSERTS',
               label: 'Inserts'
           }
           ,
           {
               field: 'UPDATES',
               label: 'Updates'
           }
           ,
           {
               field: 'TOTAL_UPDATES',
               label: 'Total Updates'
           }
           ,
           {
               field: 'LAST_ACTION_DATE',
               label: 'Last Action Date'
           }
        ];

【问题讨论】:

    标签: kendo-ui kendo-grid asp.net-web-api


    【解决方案1】:

    有同样的问题,所以我查了一下,我就在这里。您只需要按原样返回包含参数映射的“选项”,如果您将其字符串化,它将成为无法在 url 中定义的 json 对象。 希望我不会太晚!

    【讨论】:

      猜你喜欢
      • 2014-02-18
      • 1970-01-01
      • 2013-11-23
      • 1970-01-01
      • 2018-08-15
      • 1970-01-01
      • 2017-05-10
      • 2017-01-19
      • 1970-01-01
      相关资源
      最近更新 更多