我遇到了一個頭疼的問題,當我用dojo開發一個前端UI時。我有谷歌這個問題很長一段時間。郵遞員和bugtracker也是如此。dojo datagrid只顯示一行
當我用TabContainer打開一個頁面並切換到Tab時,Tab中的DataGrid沒有正確顯示。現在我切換到另一個Tab並再次切換回來,網格正確顯示。我在Declarative dojo 。只有一行javascript代碼。
<script>
function imgFormatter(s) {
return '<img src="' + s + '"/>';
}
</script>
的情況是這樣的: 打開頁面 http://i.stack.imgur.com/QGeid.png
切換到另一個選項卡,並再次siwtch回 http://i.stack.imgur.com/OWQxR.png
代碼:
<div data-dojo-type="dijit.layout.TabContainer" data-dojo-props="region: 'center'">
<div data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="region: 'center'" title="tab1">
tab1
</div>
<div data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="region: 'center'" title="Hosts">
<div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region: 'center'">
<div data-dojo-type="dojo.data.ItemFileReadStore" data-dojo-props="url: dojo.config.api2Path + '/GangliaHostMetric', urlPreventCache:true, clearOnClose:true" data-dojo-id="gangliaHostSummaryStore"></div>
<table data-dojo-type="dojox.grid.DataGrid" data-dojo-props="region: 'center', query : {}, store:gangliaHostSummaryStore" data-dojo-id="gangliaHostSummaryGrid">
<thead>
<tr>
<th field="hostname">hostname</th>
<th field="load_report" width="300" formatter="imgFormatter">Load</th>
<th field="mem_report" width="300" formatter="imgFormatter">Memory</th>
<th field="network_report" width="300" formatter="imgFormatter">Network</th>
<th field="cpu_report" width="300" formatter="imgFormatter">CPU</th>
</tr>
</thead>
</table>
</div>
</div>
</div>
非常好!非常感謝。我已經嘗試了第一種方法,並且所有的東西都是解決方法! – HackieChain 2012-07-20 08:33:07
現在我正在使用Dgrid而不是dojox/grid。 dojox/grid是越野車和頭痛。 – HackieChain 2012-10-11 08:36:09