【问题标题】:No data showing in dojox.grid.DataGriddojox.grid.DataGrid 中没有显示数据
【发布时间】:2009-10-30 21:41:02
【问题描述】:

我正在使用 dojo 1.3,但无法让这个 dojox.grid.DataGrid 正常工作。我确信这是我的无知。我一直在阅读 Dojo Campus 的示例,并且相信我是对的。我的 html 看起来像:

<script type="text/javascript">
dojo.require("dojox.grid.DataGrid");
dojo.require("dojo.data.ItemFileWriteStore");
</script>

    <div dojoType="dojo.data.ItemFileWriteStore" jsId="forumsStore" url="action/forum.JsonForums"></div>

    <div id="ForumsListingArea" name="ForumsListingArea">
        <div id="ListOfForumsContainer" name="ListOfForumsContainer">
            <table dojoType="dojox.grid.DataGrid" query="{ID:'*'}" store="forumsStore" clientSort="true" style="width: 100%; height: 100%;"  id="ListOfForums" name="ListOfForums">
                <thead>
                    <tr>
                        <th field="title" width="200px">Title</th>
                        <th field="commentCount" width="200px"># Of Posts</th>
                        <th field="description" width="200px">Moderators</th>
                        <th width="200px">Del|Config</th>
                    </tr>
                </thead>
            </table>
        </div>
    </div>

萤火虫显示从数据存储返回的数据为:

{identifier:"ID",items:[{"ID":"1","description":"Test Forum","title":"Test","topics":[],"commentCount":"0"}]}

呈现内容时,我列出了表格列,但没有显示数据。我错过了什么明显的东西吗?

谢谢

【问题讨论】:

    标签: javascript dojo


    【解决方案1】:

    这绝对不是你的错。尝试从以下位置更改桌子上的样式:

    style="width: 100%; height: 100%;"
    

    到这样的事情:

    style="width: 900px; height: 300px;"
    

    我不确定它在内部是如何工作的,但我发现网格代码几乎无法使用,因为这样的东西。我喜欢的“功能”太多了。

    我希望这对你有用,它在版本 1.2.3 上为我修复了它。

    【讨论】:

    • 你是在暗示我要为更多的问题做准备吗?自己抽出行列表很容易。
    • 声明性字段绑定增加了相当多的价值,所以我不会说它不值得头疼。我想这取决于您显示的数据的性质以及您需要像网格一样。另一个问题:网格单元的高度必须完全相同。在大多数网格中,都是这种情况(一行文本)。但是对于我的用例,我有一行是一段文本,每行都有不同的大小。当您向下滚动一个大列表时,这会导致一些奇怪的行为。不容易调试。
    • 我一整天都在敲我的头,突然'style="width:900px;height:300px"',它出现了。如果不是在 dojo 中的良好集成、丰富的 UI 和数据存储,更不用说内部化,我会永远离开 dojo。
    【解决方案2】:

    尝试删除标识符,这是我使用的,它对我有用 {项目:[{"Title":"HelloTitle","Year":"2010","Producer":"foo"},{"Title":"HelloTitle2","Year":"2110","Producer" :"f2232312164oo"}]}

    【讨论】:

    • 我遇到了一个类似的问题(尽管我在代码中加载了网格)并删除了修复它的标识符。但是,您能解释一下为什么这样可以解决问题吗?
    【解决方案3】:

    我刚刚在 v1.7.1 中遇到了同样的问题,而为我解决的问题确实是给网格一个固定的高度,比如

    #grid { height:500px !important; }
    

    如果没有!important,它就无法工作,因为出于某种晦涩的原因,dojo 一直为该元素分配 0px 高度的内联样式...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-03-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多