0

我正在尝试使用以下代码创建 Dojo 布局:

require([ 'dijit/registry', 'dijit/layout/BorderContainer', 'dijit/layout/TabContainer', 'dijit/layout/ContentPane', 'dojo/store/Memory', 'gridx/core/model/cache/Sync', 'gridx/Grid', 'dojox/dgauges/components/default/HorizontalLinearGauge', 'dojox/charting/Chart', 'dojo/domReady!' ], function(
  registry,
  BorderContainer,
  TabContainer,
  ContentPane,
  Memory,
  Sync,
  Grid,
  HorizontalLinearGauge,
  Chart
) {
Layout = new BorderContainer({
  'design' : 'headline',
  'class': 'borderContainerLayout'
}, 'dashboardLayout');
Layout.addChild(new ContentPane({
  'id': 'layoutRight',
  'region' : 'right',
  'content': '<div id="days-between-purchases"></div>',
  'splitter': true
}));
Layout.startup();
var hlg = new HorizontalLinearGauge({
  'title': 'Purchase Cycle (Average # of days between purchases)',
  'srcRefNode': 'abc',
  'value': 20,
  'class': 'gauge',
  'noChange': true,
  'width': 150,
  'height': 150,
  'min': 0,
  'max': 100,
}, registry.byId('days-between-purchases'));
hlg.render();

有更多代码可以向 BorderContainer 添加中心、左侧等,但我遇到的问题是“无法获取未定义或空引用的属性 'nodeType'。从当时捕获的 DOM 来看,似乎布局尚未呈现到 DOM 中,因此它找不到 registry.byId('days-between-purchases')。我尝试了大约 10 种不同的方法来尝试将其放在一起以在运行时呈现布局和仪表并进行搜索大量寻求解决方案,但一无所获。

我究竟做错了什么?你知道一个教程,它展示了如何在运行时使用仪表完全渲染布局吗?示例代码?

提前致谢。

仅供参考:我正在使用最新版本的 dojo 和这个 dojoConfig:

var dojoConfig = {
baseUrl : "//ajax.googleapis.com/ajax/libs/dojo/1.9.1/",
async : true,
isDebug : true,
parseOnLoad : false,
//gfxRenderer: "svg,silverlight,vml",

packages : [ {
  name : "dojo",
  location : "dojo"
}, {
  name : "dijit",
  location : "dijit"
}, {
  name : "dojox",
  location : "dojox"
}, {
  'name': 'gridx',
  'location': '/resources/common/javascript/gridx'
}]

};

4

1 回答 1

1

由于您的样本似乎无法完全运行,因此很难理解发生了什么?特别是我不认为仪表有一个 render() 方法,而你正在调用它?

在 dojox/dgauges/tests/test_all.html 中,您将找到一个显示 BorderContainer 中使用的仪表的测试。也许它可以提供帮助。

于 2013-10-08T20:52:06.963 回答