2011-11-28 182 views
2

我想添加2个面板到已创建的面板(布局:拉伸,类型:hbox)。我在萤火虫中没有错误,但在我的屏幕上似乎没有发生任何错误。ExtJS添加面板到面板

下面是将2个面板添加到已定义面板的代码。

var variablesAttributesPanel = new Ext.Panel({ 
    id: 'variablesAttributesPanel', 
    title: 'variablesAttributesPanel', 
    autoScroll: true, 
    html: 'yeah1', 
    layout: { 
     align: 'stretch', 
     type: 'vbox' 
    }, 
    flex: 1 
}); 
var locationDatePanel = new Ext.Panel({ 
    id: 'locationDatePanel', 
    autoScroll: true, 
    title: 'locationDatePanel', 
    html: 'yeah2', 
    layout: { 
     align: 'stretch', 
     type: 'vbox' 
    }, 
    flex: 1 
}); 
Ext.getCmp('datasetInfoPanel').add(variablesAttributesPanel); 
Ext.getCmp('datasetInfoPanel').add(locationDatePanel); 
Ext.getCmp('datasetInfoPanel').update(); 
Ext.getCmp('datasetInfoPanel').doLayout(); 

关于我在做什么的错误?

编辑

var datasetInfoPanel = new Ext.Panel({ 
    id: 'datasetInfoPanel', 
    title: "Dataset Information", 
    region: "center", 
    autoScroll: true, 
    layout: { 
     align: 'stretch', 
     type: 'hbox' 
    }, 
}); 
+0

你可以显示你配置datasetInfoPanel的代码,问题似乎是你没有给面板尺寸。 – nscrob

+1

和另一件事。我不知道你使用的是什么版本的extjs,但更新方法不是刷新视图,而是给面板一个新的html或数据内容。看到文档,所以基本上你用一个空的html重写了面板视图。 – nscrob

+0

你在Ext.onready()当然这么做? – Mchl

回答

1

尝试:

datasetInfoPanel.add(variablesAttributesPanel); 
datasetInfoPanel.add(locationDatePanel); 

删除布局从variablesAttributesPanel和locationDatePanel confing。