Question

Im using Dojo 1.7.1 dojo.store.JsonRest to fill an EnhancedGrid with data. However using Firebug I do not see any queries sent neither on startup nor on filtering afterwarts. The Table remains empty.

Overview: An enhanced Grid and a JsonRest Store are created declaratively. The Store is configured to use a REST Service with GET functionallity only that returns a Json Array with 1 Element. A button calls the Grids filter function to test if queries are sent after startup.

The Service Returns a static Json String like the following:

[{id:'1',firstname:'John',lastname:'Doe'}] 

The Source Code is here:

<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>

Im new to Restful Webservices and I would appreciate some help solving this.

Was it helpful?

Solution

This might not be your only problem but I notice you're using the older EnhancedGrid but with the newer dojo.store.JsonRest without an ObjectStore. Please refer to this page for more details. Here is an extract:

The 1.6 DataGrid is still based on the dojo.data API, so we will use the dojo.data.ObjectStore adapter to connect our store to the DataGrid.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top