本文介绍了kendo网格服务器端过滤并且不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是Kendo网格,具有服务器端过滤,排序和分页功能.

I'm using a Kendo Grid, with Server Side Filtering, Sorting and Pagination.

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

This my code for initializing the Grid:

在此代码中,服务器端分页和虚拟滚动有效,但过滤和短路无效.

In this code Server side pagination and virtual scroll is working but filtering and shorting is not working.

在任何要求下,我都会得到这个

In any request, I am getting this

请求参数的类型.

[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) }]

        });

推荐答案

 $("#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) }]

    });

这篇关于kendo网格服务器端过滤并且不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-12 06:40