Javascript 配置dojo datagrid以使用远程服务器URL
我无法将dojo数据网格配置到远程服务器。我下面的教程示例是: 我的代码是用一个jsp编写的,如下所示:Javascript 配置dojo datagrid以使用远程服务器URL,javascript,html,dojo,Javascript,Html,Dojo,我无法将dojo数据网格配置到远程服务器。我下面的教程示例是: 我的代码是用一个jsp编写的,如下所示: <!DOCTYPE HTML> <html lang="en"> <head> <meta charset="utf-8"> <title>Demo: dojox.grid.DataGrid Simple Structure</title> <link re
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Demo: dojox.grid.DataGrid Simple Structure</title>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dojo/resources/dojo.css">
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dojox/grid/resources/Grid.css">
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dojox/grid/resources/claroGrid.css">
<!-- load dojo and provide config via data attribute -->
<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.6.0/dojo/dojo.xd.js"
data-dojo-config="isDebug: true,parseOnLoad: true">
</script>
<script>
dojo.require("dojox.grid.DataGrid");
dojo.require("dojo.data.ItemFileWriteStore");
var grid, store;
dojo.ready(function(){
store = new dojo.data.ItemFileWriteStore({
url: "MilestoneAjaxPopulateMsListEditor.json"
});
grid = new dojox.grid.DataGrid({
query: { id: "*" },
store: store,
structure: [
{ name: "First Name", field: "first", width: "25%" },
{ name: "Last Name", field: "last", width: "25%" }
]
},dojo.byId("grid"));
grid.startup();
});
</script>
</head>
<body class="claro">
<%@ include file="ui_init.jsp" %>
<h1>Demo: dojox.grid.DataGrid Simple Structure</h1>
<br/>
<div id="grid"></div>
<%@ include file="footer.jsp" %>
</body>
</html>
我得到的错误是:
有关此错误的任何指针,请提供帮助。要使ItemWriteStore正常工作,json的数组部分应指定键名为“items”,并且json对象需要具有键“id”,如果没有,则还需要指定哪个键将作为json对象的id
{"identifier:"first","items":[
{"first":"146", "last":"Concept Commit"}
, {"first":"147", "last":"Execution Commit"}
, {"first":"148", "last":"EFT Start"}
, {"first":"149", "last":"Throttle Pull Review"}]}
但是,下面的官方教程是如何工作的:我可以通过调整数据网格中两列的宽度来解决“发生错误”的消息,使两列的宽度都达到100%。但现在我认为JSON数据没有被正确读取,我看到的是只有数据网格标题的空白屏幕。
{"identifier:"first","items":[
{"first":"146", "last":"Concept Commit"}
, {"first":"147", "last":"Execution Commit"}
, {"first":"148", "last":"EFT Start"}
, {"first":"149", "last":"Throttle Pull Review"}]}