gpt4 book ai didi

javascript - 0x800a01bd - JavaScript 运行时错误 : Object doesn't support this action - Kendo UI

转载 作者:行者123 更新时间:2023-11-30 05:46:13 25 4
gpt4 key购买 nike

我做错了什么?我想要做的就是从 API 获取一些数据并将其显示在屏幕上:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Kendo UI Test</title>
<link href="styles/kendo.common.min.css" rel="stylesheet" />
<link href="styles/kendo.default.min.css" rel="stylesheet" />
<script src="js/jquery.min.js"> </script>
<script src="js/kendo.web.min.js"> </script>
</head>
<body>
<div id="grid"></div>

<script type="text/javascript">
$(document).ready(function()
{
var retrievedData = new kendo.data.dataSource({
transport: {
read: {
url: "http://puppygifs.tumblr.com/api/read/json",
dataType: "json"
}
}
});

$("#grid").kendoGrid({
dataSource: retrievedData,
pageSize: 10
});
});

</script>
</body>
</html>

错误发生在这部分:

var retrievedData = new kendo.data.dataSource({
transport: {
read: {
url: "http://puppygifs.tumblr.com/api/read/json",
dataType: "json"
}
}
});

编辑:

我将如何修改代码以从如下所示的对象中捕获数据:

[
{
<NotificationNode>k__BackingField: {
isDirty: false,
isRecordAdded: false,
isRecordDeleted: false,
<CaseStatus>k__BackingField: null,
<CaseName>k__BackingField: null,
<CaseType>k__BackingField: null,
<CaseStage>k__BackingField: null,
<CaseNotificationId>k__BackingField: 0,
<CaseId>k__BackingField: 0,
<Comments>k__BackingField: null,
<WarningDays>k__BackingField: 0,
<NotificationDate>k__BackingField: "0001-01-01T00:00:00",
<LetterUrl>k__BackingField: null,
<NotificationId>k__BackingField: 0,
<NotificationDescription>k__BackingField: null,
<NotificationCount>k__BackingField: 1889,
<ParamValue1>k__BackingField: null,
<ParamValue2>k__BackingField: null,
<ParamValue3>k__BackingField: null,
<ParamValue4>k__BackingField: null,
<ParamValue5>k__BackingField: null,
<NotificationStatus>k__BackingField: 0,
<Checked>k__BackingField: false,
notificationTypeId: 1,
notificationType: "Add/Edit Gross Earnings",
actionPageName: null,
param1: null,
param2: null,
param3: null,
param4: null,
param5: null,
dateEntered: "0001-01-01T00:00:00",
whoEntered: 0,
dateChanged: "0001-01-01T00:00:00",
whoChanged: 0
},
<Notifications>k__BackingField: [ ],
<IsExpanded>k__BackingField: false
},

最佳答案

你的dataSource选项打错了,它必须是DataSource;您正在读取的数据来自另一个来源,因此您可以使用 jsonp 作为 dataType

提供的服务返回一组复杂的数据,您必须只读取要在网格中显示的数据并绑定(bind)要在列中显示的数据。

您可以使用 schema 执行此操作和 columns参数。

代码:

  $(document).ready(function () {
var retrievedData = new kendo.data.DataSource({
transport: {
read: {
url: "http://puppygifs.tumblr.com/api/read/json",
dataType: "jsonp"
}
},
schema: {
data: "posts"
}
});
$("#grid").kendoGrid({
dataSource: retrievedData,
columns: [{
field: "id",
title: "ID",
width: 150
}, {
field: "url",
title: "URL",
width: 150
}]
});
});

工作演示: jsFiddle

关于javascript - 0x800a01bd - JavaScript 运行时错误 : Object doesn't support this action - Kendo UI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17847146/

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