【问题标题】:No Query are sent using Dojo Json Rest Store with Enhanced DataGrid没有使用带有增强型 DataGrid 的 Dojo Json Rest Store 发送查询
【发布时间】:2012-01-23 13:49:30
【问题描述】:

我正在使用 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 的新手,如果能帮助我解决这个问题,我将不胜感激。

【问题讨论】:

    标签: json rest dojo dojox.grid.datagrid


    【解决方案1】:

    这可能不是您唯一的问题,但我注意到您使用的是旧的 EnhancedGrid,但使用的是没有 ObjectStore 的较新的 dojo.store.JsonRest。 详情请参阅this page。这是摘录:

    1.6 DataGrid 仍然基于 dojo.data API,因此我们将使用 dojo.data.ObjectStore 适配器将我们的商店连接到 DataGrid。

    【讨论】:

    • 是的,这似乎确实是我的大部分问题,但是使用 dojo.data.ObjectStore 适配器我的代码仍然无法正常工作,所以我必须解决更多问题。
    猜你喜欢
    • 2011-10-11
    • 2013-12-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多