dojox.layout.ContentPane中的dojox.Grid必须设置height,否则无法显示

我在页面中通过dojox.layout.ContentPane载入一个子页面。子页面中放置了一个dojox.Grid。

<style type="text/css"> 
@import "js/dojox/grid/_grid/tundraGrid.css"; 
</style> 
<script type="text/javascript"> 
dojo.require("dojox.grid.Grid"); 
dojo.require("dojox.grid._data.model"); 
dojo.require("dojo.data.ItemFileReadStore"); 

// a grid view is a group of columns. 
var logview = { 
cells: [[ 
{name: 'level', field: "level"}, 
{name: 'className', field: "className"}, 
{name: 'fileName', field: "fileName"}, 
{name: 'lineNumber', field: "lineNumber"}, 
{name: 'methodName', field: "methodName"}, 
{name: 'loggerName', field: "loggerName"}, 
{name: 'startDate', field: "startDate"}, 
{name: 'logDate', field: "logDate"}, 
{name: 'threadName', field: "threadName"} 
], 
[ 
{name: 'message', colSpan:"9", field: "message"} 
] 
] 
}; 
// a grid layout is an array of views. 
var log_layout = [ logview ]; 

var log_jsonStore1  = new dojo.data.ItemFileReadStore({url:'jsondata/log.js'}); 
var showlog_model = new dojox.grid.data.DojoData(null, log_jsonStore1, {query:{ level: '*' }, clientSort:true}); 
</script> 
<div id="grid"  dojoType="dojox.Grid" model="showlog_model" structure="log_layout"></div>

无论是静态创建dojox.Grid,还是用js动态创建,这个grid都无法显示。

var grid = new dojox.Grid({ 
"id": "logger_grid", 
"model": showlog_model, 
"structure": log_layout 
}); 
dojo.byId("gridContainer").appendChild(grid.domNode); 
grid.render();

后来发现,如果给grid所在的div加一个style="height: 500px;" ,问题就解决了。
参见:http://trac.dojotoolkit.org/ticket/6055

此博客中的热门博文

少写代码,多读别人写的代码

在windows下使用llvm+clang

tensorflow distributed runtime初窥