Kendoui网格服务器过滤未将数据传递到控制器



我在我的MVC项目中实现了kendo ui网格。我想执行服务器过滤,但我没有将过滤对象进入控制器。我尝试了以下代码。

JS代码:

$("#AccountLedgerReport").kendoGrid({
        toolbar: ["excel", "pdf"],
        excel: {
            allPages: true,
            filterable: true
        },
        pdf: {
            filterable: true
        },
        dataSource: {
            type: "aspnetmvc-ajax",
            serverSorting: true,
            serverPaging: true,
            serverFiltering: true,
            transport: {
                read: getActionURL() + "url?site....,
                type: "POST",
                dataType: "json"
            },
            pageSize: 50,
            schema: {                    
                    return data;
                },
                data: 'data',
                total: 'total',
                model: {
                    fields: {                        
                        PnrNumber: { type: "string" }
                        , TransactionId: { type: "number" }
                        , CreatedByName: { type: "string" }
                        ...
                    }
                },
            },
            aggregate: [
                { field: "xxx", aggregate: "max" }                    
            ]
        },
        dataBound: onDataBound, 
        sortable: true,
        filterable: true,
        columnMenu: true,
        filterable: {
            mode: "row"
        },    
        pageable: {
            refresh: true,
            pageSizes: true,
            buttonCount: 5,
            serverFiltering: true,
            pageSizes: 50
        }, 
        columns: [
        {
            field: "x",
            title: "x",
            format: x,
            width: 145,
            footerTemplate: 'Total :',
            filterable: {
                cell: {
                    showOperators: true
                }
            },
        },...
        ]
    });

然后我要获取数据的控制器侧是:

public JsonResult actionname(int site..., IDictionary<string, string>[] sort, .., IDictionary<string, Tuple<string, string, string>[]> filter)

这里我面临的挑战是滤波器参数。当需要时,分类的数据即将到来,但过滤器的数据不会到来。

请求URL如下:

https://localhost/...?site..&sort[0][field]=xx&sort[0][dir]=asc

这是完成排序的时候。

https://localhost/..?site...&filter[logic]=and&filter[filters][0][operator]=eq&filter[filters][0][value]=held&filter[filters][0][field]=xxx

这是过滤器正在处理的时候。

我没有得到我做错的地方。

根据官方文档详细信息,操作方法中剩下的参数很少,因此请使用以下内容更新您的控制器操作。不幸的是,我以前遇到过这个问题,并在我的尽头解决了。这样,排序和过滤器将完美工作。请尝试这种方法。

JS代码

$("#AccountLedgerReport").kendoGrid({
        toolbar: ["excel", "pdf"],
        excel: {
            allPages: true,
            filterable: true
        },
        pdf: {
            filterable: true
        },
        dataSource: {
            type: "aspnetmvc-ajax",
            serverSorting: true,
            serverPaging: true,
            serverFiltering: true,
            transport: {
                read: getActionURL() + "url?site....,
                type: "POST",
                dataType: "json"
            },
            pageSize: 50,
            schema: {                    
                    return data;
                },
                data: 'data',
                total: 'total',
                model: {
                    fields: {                        
                        PnrNumber: { type: "string" }
                        , TransactionId: { type: "number" }
                        , CreatedByName: { type: "string" }
                        ...
                    }
                },
            },
            aggregate: [
                { field: "xxx", aggregate: "max" }                    
            ]
        },
        dataBound: onDataBound, 
        sortable: true,
        filterable: true,
        columnMenu: true,
        filterable: {
            mode: "row"
        },    
        pageable: {
            refresh: true,
            pageSizes: true,
            buttonCount: 5,
            serverFiltering: true,
            pageSizes: 50
        }, 
        columns: [
        {
            field: "x",
            title: "x",
            format: x,
            width: 145,
            footerTemplate: 'Total :',
            filterable: {
                cell: {
                    showOperators: true
                }
            },
        },...
        ]
    });

动作控制器

public JsonResult YourActionName(int id, DateTime startDate, DateTime endDate, int take, int skip, int page, IDictionary<string, string>[] sort, int dateFilterOn, string number)

最新更新