我在选项卡面板(使用 Ext Designer 制作)中重新排列网格时遇到问题。层次结构如下, 视口(viewport)。 -> tabPanel -> 面板 -> 容器 -> 网格。
现在是这样显示的
这是视口(viewport)的代码
mainWindowUi = Ext.extend(Ext.Viewport, {
layout: 'border',
id: 'mainWindow',
initComponent: function() {
this.items = [
{
xtype: 'panel',
title: 'Navigation',
region: 'west',
width: 200,
frame: true,
split: true,
titleCollapse: true,
collapsible: true,
id: 'navigation',
items: [
{
flex: 1,
xtype: 'mytreepanel'
}
]
},
{
xtype: 'tabpanel',
layoutOnTabChange: true,
resizeTabs: true,
defaults: {
layout: 'fit',
autoScroll: true
},
region: 'center',
tpl: '',
id: 'mainTabPanel',
layoutConfig: {
deferredRender: true
}
}
];
mainWindowUi.superclass.initComponent.call(this);
}
});
这里是创建标签的代码..(以编程方式从导航面板创建)
var currentTab = tabPanel.findById(node.id);
// If not yet created, create the tab
if (!currentTab){
currentTab = tabPanel.add({
title:node.id,
id:node.id,
closable:true,
items:[{
xtype: 'phasePanel',
layout: 'fit',
autoscroll: true,
}],
autoScroll:true,
});
}
// Activate tab
tabPanel.setActiveTab(currentTab);
这是面板/容器/网格的代码
PhasePanelUi = Ext.extend(Ext.Panel, {
frame: true,
layout: 'anchor',
autoScroll: true,
autoWidth: true,
defaults: '',
initComponent: function() {
this.items = [
{
xtype: 'container',
autoScroll: true,
layout: 'fit',
defaults: {
layout: 'fit',
autoScroll: true
},
id: 'gridHolder',
items: [
{
xtype: 'grid',
title: 'Current Phases',
store: 'PhaseStore',
autoDestroy: false,
viewConfig: '',
deferRowRender: false,
autoLoad: '',
ref: '../phaseGrid',
id: 'phaseGrid',
columns: [
{
xtype: 'gridcolumn',
header: 'Name',
dataIndex: 'name',
sortable: true,
width: 200
},
{
xtype: 'gridcolumn',
header: 'Estate',
dataIndex: 'estate_name',
sortable: true,
width: 500
}
]
}
]
}
];
PhasePanelUi.superclass.initComponent.call(this);
}
});
我试过各种组合。但只是无法让网格正确呈现任何形式的帮助将不胜感激。
最佳答案
您的 currentTab 也需要“适合”的布局...您为 phasePanel 提供了“适合”的布局,为 phasePanel 中的容器提供了“适合”的布局,但您没有为 currentTab 提供“适合”的布局适合'...
布局指的是子项目在容器中的布局方式……而不是项目如何适合其容器。因此,如果您希望项目适合其容器,请在容器上设置 layout:'fit',而不是项目。
关于javascript - TabPanel 中的 ExtJs Grid 自动调整问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5063282/