0

I am trying to show some json data retrieved from a REST server (implemented in Zend Framework) in a datagrid. Problem is that the data grid just shows "Loading..." and nothing more happens. In Firebug Lite, I can see the GET request performed and the response is ok. Still the data is not rendered in the data grid, very confusing.

Basically, I have copy'n'pasted this code from "Connecting a Store to a DataGrid" and just replaced the target url and structure to suite my REST api.

I am using Dojo 1.7.2 and Zend Framework 1.11.11

this is my index.phtml file.

<!DOCTYPE HTML>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Demo: Connecting DataGrid to a Store</title>

        <link rel="stylesheet" href="/js/dojo/dojox/grid/resources/claroGrid.css" media="screen">
        <!-- load dojo and provide config via data attribute -->
        <script type="text/javascript" src="/js/dojo/dojo/dojo.js"
                data-dojo-config="isDebug: true,parseOnLoad: true">
        </script>
        <script>
            dojo.require("dojo.store.JsonRest");
            dojo.require("dojo.store.Memory");
            dojo.require("dojo.store.Cache");
            dojo.require("dojox.grid.DataGrid");
            dojo.require("dojo.data.ObjectStore");
            dojo.ready(function(){
                myStore = dojo.store.Cache(dojo.store.JsonRest({target:"api/testresults/"}), dojo.store.Memory());
                grid = new dojox.grid.DataGrid({
                    store: dataStore = dojo.data.ObjectStore({objectStore: myStore}),
                    structure: [
                        {name:"Test case", field:"testCase", width: '25%'},
                        {name:"Verdict", field:"verdict", width: '25%'},
                        {name:"Device under test", field:"deviceUnderTest", width: '25%'},
                        {name:"Test environment", field:"environment", width: '25%'}
                    ]
                }, "target-node-id"); // make sure you have a target HTML element with this id
                grid.startup();
                });
        </script>
    </head>
    <body>
        <h1>Demo: Connecting DataGrid to a Store</h1>
        <div id="target-node-id"></div>
        </body>
</html>

The GET request done by the JsonRestStore as it appears in Firebug Lite:

ResponseHeaders
Date    Fri, 08 Jun 2012 12:59:41 GMT
X-Powered-By    PHP/5.3.8
Content-Range   items 0-24/2
Connection  Keep-Alive
Content-Length  229
Server  Apache/2.2.21 (Win32) mod_ssl/2.2.21 OpenSSL/1.0.0e PHP/5.3.8 mod_perl/2.0.4 Perl/v5.10.1
Content-Type    application/json
Keep-Alive  timeout=5, max=73

RequestHeaders
Accept  application/javascript, application/json
Range   items=0-24
Content-Type    application/x-www-form-urlencoded
X-Requested-With    XMLHttpRequest

This is the JSON data as a result of the GET request

[ { "deviceUnderTest" : "R1B583",
        "environment" : "Example1",
        "id" : "1",
        "testCase" : "COH901359_12_001_001",
        "verdict" : "FAIL"
      },
      { "deviceUnderTest" : "R1B583",
        "environment" : "Example2",
        "id" : "2",
        "testCase" : "COH901359_12_001_002",
        "verdict" : "PASS"
      }
    ]
4

1 回答 1

1

似乎实际上是 Firbug Lite (Google Chrome) 阻止了数据网格显示数据......一旦我禁用它,数据就会按预期呈现。

于 2012-06-09T09:11:32.427 回答