0

我正在以编程方式创建 DOJO TabContainer 和 ContentPanes 以添加到该 tabContainer。每个 contentPanes 都包含我的自定义小部件。部分代码如下所示。显示选项卡时,第一个选项卡上的 containerNode 的高度为 0px,因此即使第一个选项卡具有完全加载的小部件,但它不会显示在浏览器中。这曾经在 1.6 中正常工作。我已将 dojo 1.6 替换为 1.9.3 并遇到了这个问题。有任何想法吗?

    var availableWidgets = { 
'Name': {title: 'Name', widget:'test.ui.NameWidget'},
'Stats':    {title: 'Stats', widget:'test.ui.StatsWidget'}

};

postCreate: function(){ 
var tabContainer = new dijit.layout.TabContainer({controllerWidget: "dijit.layout.TabController"}, this.pContainerDiv);                     
tabContainer.set('class', 'claro');
tabContainer.set('doLayout', false);
tabContainer.set('style', "width: 100%; height: 100%;"); 

dojo.forEach(this.menuItems, dojo.hitch(this, function(menuItem, index){
    var widgetInfo = availableWidgets[menuItem];
if(widgetInfo != null){
    var contentPaneId = portletNamespace + pContext.persistentId + menuItem + 'ContentPane';

    var contentPane = new dijit.layout.ContentPane({
    id: contentPaneId,
            title: widgetInfo.title,
    selected: currentSelectedItem == menuItem,
    closable: false,
    style: 'height:100%;padding: 15px;',
    onShow: dojo.hitch(this, function(){                               
       //can no longer do this in 1.9
       //dojo.require(widgetInfo.widget);                             
       if (widgetInfo.widget == 'test.ui.NameWidget') {
           dojo.require("test.ui.NameWidget");
       } else if (widgetInfo.widget == 'test.ui.StatsWidget') {
           dojo.require("test.ui.StatsWidget");
       } 

       var currentView = this.widgets[widgetInfo.title];
       if(!currentView){
           currentView = eval('new ' + widgetInfo.widget + '(this.params)');
           currentView.placeAt(contentPaneId, 'last'); 

           // startup called by (dijit/_WidgetBase in 1.9.3) by placeAt above
           // currentView.startup(); 

           this.widgets[widgetInfo.title] = currentView;                                    
           }                                
            })
    });                   
        tabContainer.addChild(contentPane);
    }
}));

}

4

2 回答 2

0

我有一个修复。在将内容窗格添加到选项卡容器之前,我现在调用:

tabContainer.startup();

在使用 dojo 1.6 时,我是在将所有内容窗格添加到选项卡容器后执行此操作的。在修复高度问题之前调用它并使用 dojo 1.9.3 正确呈现所有选项卡。

于 2014-05-13T20:59:04.310 回答
0

将小部件添加到内容窗格后,我会尝试在内容窗格上调用 .resize() 。那应该正确调整内容窗格的大小。另一种选择是在将子项添加到 contentPane 之后,通常在 tabcontainer 上调用 .resize()。

于 2014-05-09T00:29:07.783 回答