kendo网格服务器端过滤而无法正常工作

时间:2017-10-16 07:06:59

标签: sorting kendo-ui pagination kendo-grid kendo-asp.net-mvc

enter image description here

我正在使用Kendo Grid,具有服务器端过滤,排序和分页功能。

这是我初始化网格的代码:

在此代码中,服务器端分页和虚拟滚动正在运行,但过滤和短路不起作用。

在任何请求中,我都会收到此

enter image description here

请求参数的类型。

[HttpPost]
public JsonResult getGridData([DataSourceRequest] DataSourceRequest request)
{
    var userList = data;
    return Json(userList.ToDataSourceResult(request));
}




  $("#grid").kendoGrid({
            dataSource: {
                type: "aspnetmvc-ajax",
                transport: {
                    read: {
                        url: "@Url.Action("getGridData", "ListMaster")",
                        type: "POST",
                        dataType: "json",
                        async: true,
                        contentType: 'application/json',
                        data: function (e) {
                            return e;
                        }
                    }
                    ,parameterMap: function (data, type) {
                    return kendo.stringify(data);
                    }
                },
                schema: {
                    data: function (result) {
                        return result.Data;
                    },
                    total: function (result) {
                        return result.Total;
                    }
                },
                pageSize: 20,
                serverPaging: true,
                serverFiltering: true,
                serverSorting: false
            },
            height: 550,
            groupable: true,
            sortable: true,
            pageable: true,
            resizable: true,
            scrollable: { virtual: true },
            filterable: { mode: 'row' },
            pageable: {
                refresh: true,
                pageSizes: true,
                buttonCount: 5
            },
            dataBound: function () {

                var data = this.dataSource.view();
            },
            columns: [{ field: "Id", title: "Id", filterable: filter(true), hidden: true },
                         { field: "Name", title: "Name", filterable: filter(true) }]

        });

1 个答案:

答案 0 :(得分:1)

 $("#grid").kendoGrid({
        dataSource: {
            type: "json",
            transport: {
                read: {
                    url: "@Url.Action("getGridData", "ListMaster")",
                    type: "POST",
                    dataType: "json",
                    async: true,
                    cache: false,
                    contentType: 'application/json',
                    data: function (e) {
                        return e;
                    }
                },
                parameterMap: function (data, type) {
                    return kendo.stringify(data);
                }
            },
            schema: {
                data: function (result) {
                    return result.Data;
                },
                total: function (result) {
                    return result.Total;
                }
            },
            pageSize: 20,
            serverPaging: true,
            serverFiltering: true,
            serverSorting: false
        },
        height: 550,
        groupable: true,
        sortable: true,
        pageable: true,
        resizable: true,
        scrollable: { virtual: true },
        filterable: { 
                mode: 'row', 
                operators: {
                string: {
                    contains: "contains"
                }
            } },
        pageable: {
            refresh: true,
            pageSizes: true,
            buttonCount: 5
        },
        dataBound: function () {

            var data = this.dataSource.view();
        },
        columns: [{ field: "Id", title: "Id", filterable: filter(true), hidden: true },
                     { field: "Name", title: "Name", filterable: filter(true) }]

    });