kendo grid server side filtering and not working

浪尽此生 提交于 2019-12-08 02:15:31

问题


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

type of request parameters.

[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:


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

    });


来源:https://stackoverflow.com/questions/46764678/kendo-grid-server-side-filtering-and-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!