gpt4 book ai didi

kendo-ui - 不支持 Kendo ui odata 请求回调

转载 作者:行者123 更新时间:2023-12-04 23:21:44 25 4
gpt4 key购买 nike

我正在使用 Kendo UI 处理 odata 网格。
问题是 ajax 请求一直包含回调参数。导致此错误的原因:不支持回调参数。当我在没有回调的情况下手动执行请求时,我的 odata 服务运行良好。
有人知道如何解决这个问题吗?

$("#grid").kendoGrid({
dataSource: new kendo.data.DataSource({
type:"odata",
serverPaging: true,
serverFiltering: true,
serverSorting: true,

transport: {
contentType: "application/json; charset=utf-8",
type: "GET",
read: "/odata/FestivalSignUps?$inlinecount=allpages&$expand=PrefferedTasks/Task,AvailableDays,ApplicationUser",
dataType: "json",
parameterMap: function (options, type) {
var paramMap = kendo.data.transports.odata.parameterMap(options);
delete paramMap.$format; // <-- remove format parameter.

return paramMap;
}
},


pageSize: 10,
schema: {
data: function (data) {
return data["value"];
},
total: function (data) {
return data["odata.count"];
},

}
}),
filterable:true,
sortable: true,
pageable: {
refresh: true,
pageSizes: true,
buttonCount: 5
},
columns: [
{ field: "ApplicationUser.Email", width: 90, title: "Email" },

{ field: "ApplicationUser.FirstName", width: 90, title: "Voornaam" },

{ field: "ApplicationUser.LastName", width: 90, title: "Achternaam" },
{ field: "PrefferedTasks", width: 90, title: "Taken",
template: "#= formatTasks(data) #"},
{ field: "Beschikbaar", width: 90, title: "Taken" }
]

});

更新
这段代码解决了这个问题:
 $("#grid").kendoGrid({
dataSource: new kendo.data.DataSource({

type: 'odata',

transport: {
read: {
url: "/odata/FestivalSignUps?$expand=PrefferedTasks/Task,AvailableDays,ApplicationUser",
dataType: "json"
},

},



schema: {
data: function (data) {
return data["value"];
},
total: function (data) {
return data["odata.count"];
},

},
pageSize: 20,
serverPaging: true,
serverFiltering: true,
serverSorting: true
}),

filterable:true,
sortable: true,
pageable: {
refresh: true,
pageSizes: true,
buttonCount: 5
},
columns: [
{ field: "ApplicationUser.Email", width: 90, title: "Email" },

{ field: "ApplicationUser.FirstName", width: 90, title: "Voornaam" },

{ field: "ApplicationUser.LastName", width: 90, title: "Achternaam" },
{ field: "PrefferedTasks", width: 90, title: "Taken",
template: "#= formatTasks(data) #"},
{
field: "AvailableDays", width: 90, title: "Beschikbaar",
template: "#= formatDays(data) #"
},
]

});

最佳答案

我在我写的博客文章中介绍了这个问题和其他一些问题:Server-Side Filtering Using KendoUI With MVC4 WebAPI and OData.

如果是查询自己的数据,不需要做跨域请求,我们可以不使用jsonp。为此,我们只需告诉 Kendo dataType读取操作是“json”。

var dataSource = new kendo.data.DataSource({
type: 'odata', // <-- Include OData style params on query string.
transport: {
read: {
url: "/api/Albums",
dataType: "json"; // <-- The default was "jsonp".
}
}
});

关于kendo-ui - 不支持 Kendo ui odata 请求回调,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23843497/

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