我使用 Dojo 1.7.1 dojo.store.JsonRest 用数据填充增强网格。但是,使用 Firebug,我看不到在启动时或在过滤后发送的任何查询。表仍然是空的。
概述: 以声明方式创建增强的 Grid 和 JsonRest Store。Store 配置为使用仅具有 GET 功能的 REST 服务,该服务返回具有 1 个元素的 Json 数组。一个按钮调用 Grids 过滤器函数来测试是否在启动后发送查询。
该服务返回一个静态 Json 字符串,如下所示:
[{id:'1',firstname:'John',lastname:'Doe'}]
源代码在这里:
<html>
<head>
<title>Rest Test</title>
<style type="text/css">
@import "js/dojo/resources/dojo.css";
@import "js/dijit/themes/claro/claro.css";
@import "js/dojox/grid/enhanced/resources/claro/EnhancedGrid.css";
@import "js/dojox/grid/enhanced/resources/EnhancedGrid_rtl.css";
</style>
<script type="text/javascript"
src="js/dojo/dojo.js"
data-dojo-config="parseOnLoad:true"></script>
<script type="text/javascript">
dojo.require("dijit.form.Button");
dojo.require("dijit.form.TextBox");
dojo.require("dojox.grid.EnhancedGrid");
dojo.require("dojox.grid.enhanced.plugins.DnD");
dojo.require("dojox.grid.enhanced.plugins.NestedSorting");
dojo.require("dojox.grid.enhanced.plugins.IndirectSelection");
dojo.require("dojo.store.JsonRest");
dojo.addOnLoad(function(){
dojo.connect(dijit.byId("filterButton"),"onClick",function(){
dijit.byId("nameTable").filter("*",true);
});
});
</script>
</head>
<body class="claro">
<button id="filterButton"
data-dojo-type="dijit.form.Button">
Filter Table
</button>
<span id="nameStore"
data-dojo-type="dojo.store.JsonRest"
data-target="http://localhost:8080/MyApp/rest/service3"/>
<table id="nameTable"
style="height:200px;"
data-store="nameStore"
data-dojo-type="dojox.grid.EnhancedGrid"
data-dojo-props="plugins:{dnd: true, nestedSorting: true, indirectSelection: true}" >
<thead>
<tr>
<th data-field="id" width="5%">ID</th>
<th data-field="firstname" width="45%">Vorname</th>
<th data-field="lastname" width="50%">Nachname</th>
</tr>
</thead>
</table>
</body>
</html>
我是 Restful Webservices 的新手,希望能得到一些帮助来解决这个问题。