gpt4 book ai didi

javascript - KendoUI 网格服务器过滤未将数据获取到 Controller

转载 作者:行者123 更新时间:2023-12-01 04:37:25 26 4
gpt4 key购买 nike

我已经在我的 MVC 项目中使用 jquery 实现了 kendo UI Grid。我想执行服务器过滤,但我没有将过滤器对象放入我的 Controller 中。我已经尝试过下面的代码。

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
}
},

},...
]
});

然后我想要获取数据的 Controller 端是:

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

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

我没有明白我做错的地方。

最佳答案

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

JS Code

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

},...
]
});

Action Controller

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

关于javascript - KendoUI 网格服务器过滤未将数据获取到 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47927446/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com