【问题标题】:dojo debugging EnhancedGrid with ItemFileReadStoredojo 使用 ItemFileReadStore 调试 EnhancedGrid
【发布时间】:2011-07-22 19:38:15
【问题描述】:

我正在学习第 3 章“掌握 Dojo”中的示例,使用 dijox.grid.Grid。我稍微修改了它以使用 dojox.grid.EnhancedGrid。我编写了一个 Web 服务,它以 dojo 所需的格式返回一些 json。我已经独立测试了 Web 服务,它返回了正确的 json。但是当我将 EnhancedGrid 与 ItemFileReadStore 放在一起时,它不会在浏览器错误控制台中产生任何错误,但也不会在网格中显示任何数据。

我可以从这里采取哪些步骤来调试它?我可以给 dojo 提供一些详细的调试标志,以便它(希望)提示我出了什么问题?

编辑:

这就是我正在做的事情:

<html>
    <head>
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/dojo/1.6.1/dojo/dojo.xd.js" djConfig="parseOnLoad:true, isDebug:true"></script>
        <link rel="stylesheet" href="/css/main.css"/>
        <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/dojo/1.6.1/dojo/resources/dojo.css"/>
        <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/dojo/1.6.1/dijit/themes/claro/claro.css"/>
        <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/dojo/1.6.1/dojox/grid/enhanced/resources/claro/EnhancedGrid.css"/>

        <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dojox/grid/enhanced/resources/EnhancedGrid_rtl.css"/>
        <script type="text/javascript">
            dojo.require("dojo.parser");
            dojo.require("dojo.data.ItemFileReadStore");
            dojo.require("dojox.grid.EnhancedGrid");
        </script>
    </head>
    </body class="claro">
        <style>
        #msgs {
            width=550px;
            height=200px;
        }
        </style>
        <div dojoType="dojo.data.ItemFileReadStore" jsId="xstore" url="/path/to/my/resource/data.json"></div>
        <table id="msgs" dojoType="dojox.grid.EnhancedGrid" store="xstore">
            <thead>
                <tr>
                    <th field="id" width="50">Id</th>
                    <th field="ts" width="100">Date</th>
                    <th field="msg" width="400">Message</th>
                </tr>
            </thead>
        </table>
    </body>
</html>

返回的javascript是这样的:

{
    "identifier":"id",
    "items":[
        {
            "id":"3425",
             "custId":"2342525225",
            "ts":"2011-07-23T07:00:00Z",
             "msg":"test message"
        }
    ]
}

我猜有一个悬而未决的问题:json 有一个额外的列未显示在表中(“custId”)。我希望这不会造成问题?!

编辑2:

另外,如果我进入 firebug 的 DOM 控制台,我可以看到 xstore 变量正确地保存了来自 JSON 的数据。

【问题讨论】:

    标签: dojo


    【解决方案1】:

    有效的两件事是:

    在表格上设置内联样式来设置宽度/高度,或者

    设置 EnhancedGrid 属性 autoHeight,这就是我最终要做的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-14
      相关资源
      最近更新 更多