Kendo UI 网格从 Dynamics CRM 获取数据
Kendo UI grid getting data from Dynamics CRM
我在从 Dynamics CRM 在线获取数据到 kendo UI 数据网格时遇到一个奇怪的问题,当我使用 chrome 浏览器检查时,有时会出现此错误
但是当我使用 CORS 时,这个错误消失了,并且我收到了新的错误,表明请求是 UNAUTHORIZED 401,
请帮我解决这个错误,在附件中你可以找到我的源代码
非常感谢
function onReady() {
$("#btnSearch").kendoButton({
click: onSearch
})
$("#kGrid").kendoGrid({
dataSource: {
type: "odata",
transport: {
read: {
type: "POST",
dataType: "Application/json",
url: 'https://cynapsyscrm.api.crm4.dynamics.com/api/data/v8.1/accounts',
xhrFields: {
withCredentials: true
}
},
parameterMap: function (options, operation) {
var paramMap = kendo.data.transports.odata.parameterMap(options);
delete paramMap.$inlinecount; // <-- remove inlinecount parameter
delete paramMap.$format; // <-- remove format parameter
return paramMap;
}
},
schema: {
data: function (data) {
return data; // <-- The result is just the data, it doesn't need to be unpacked.
},
total: function (data) {
return data.length; // <-- The total items count is the data length, there is no .Count to unpack.
}
},
serverPaging: true,
serverFiltering: true,
pageSize: 20
},
height: 550,
pageable: true,
columns: [
'AccountID',
'AccountName',
'NumberOfEmployees',
'Revenue',
'PrimaryContact',
'PrimaryContactName'
]
})
}
$(document).ready(onReady);
根据屏幕截图,您正在尝试从本地主机访问 CRM 在线域。你根本不能这样做,因为这是一个跨域问题,我认为 MS 不会启用 "localhost" 作为允许的域 :)
尝试将其部署到测试 CRM 实例或使用单元测试测试您的代码。
希望对您有所帮助
我在从 Dynamics CRM 在线获取数据到 kendo UI 数据网格时遇到一个奇怪的问题,当我使用 chrome 浏览器检查时,有时会出现此错误
但是当我使用 CORS 时,这个错误消失了,并且我收到了新的错误,表明请求是 UNAUTHORIZED 401,
请帮我解决这个错误,在附件中你可以找到我的源代码 非常感谢
function onReady() {
$("#btnSearch").kendoButton({
click: onSearch
})
$("#kGrid").kendoGrid({
dataSource: {
type: "odata",
transport: {
read: {
type: "POST",
dataType: "Application/json",
url: 'https://cynapsyscrm.api.crm4.dynamics.com/api/data/v8.1/accounts',
xhrFields: {
withCredentials: true
}
},
parameterMap: function (options, operation) {
var paramMap = kendo.data.transports.odata.parameterMap(options);
delete paramMap.$inlinecount; // <-- remove inlinecount parameter
delete paramMap.$format; // <-- remove format parameter
return paramMap;
}
},
schema: {
data: function (data) {
return data; // <-- The result is just the data, it doesn't need to be unpacked.
},
total: function (data) {
return data.length; // <-- The total items count is the data length, there is no .Count to unpack.
}
},
serverPaging: true,
serverFiltering: true,
pageSize: 20
},
height: 550,
pageable: true,
columns: [
'AccountID',
'AccountName',
'NumberOfEmployees',
'Revenue',
'PrimaryContact',
'PrimaryContactName'
]
})
}
$(document).ready(onReady);
根据屏幕截图,您正在尝试从本地主机访问 CRM 在线域。你根本不能这样做,因为这是一个跨域问题,我认为 MS 不会启用 "localhost" 作为允许的域 :)
尝试将其部署到测试 CRM 实例或使用单元测试测试您的代码。
希望对您有所帮助