2010-12-02 88 views
4

我有以下Ext.TabPanel:如何获得Ext.Panel的高度,以填补父区域

var modules_info_panel = new Ext.TabPanel({ 
    activeTab: 0, 
    defaults:{autoScroll:true}, 
    //layout: 'fit', // makes component disappear 
    viewConfig: { 
     forceFit: true //has no effect 
    }, 
    // height: auto, //error "auto isn't recognized" 
    items:[{ 
      title: 'Section 1', 
      html: 'test' 
     },{ 
      title: 'Section 2', 
      html: 'test' 
     },{ 
      title: 'Section 3', 
      html: 'test' 
     }] 
}); 

,看起来像这样:

alt text

我如何获得中间的线向下延伸至底部,以便垂直填充其父空间?

这里的的TabPanel是如何加载到regionContent

regionContent = new Ext.Panel({ 
    id: 'contentArea', 
    region: 'center', 
    autoScroll: true 
}); 


function clearExtjsComponent(cmp) { 
    var f; 
    while(f = cmp.items.first()){ 
     cmp.remove(f, true); 
    } 
} 

function replaceComponentContent(cmpParent, cmpContent) { 
    clearExtjsComponent(cmpParent); 
    cmpParent.add(cmpContent); 
    cmpParent.doLayout(); 
} 

replaceComponentContent(regionContent, modules_info_panel); 

我看到的高度是在DOM这个元素绝对(19px),其中是被设置?

alt text

附录

McStretch,我想你的想法通过把layout: 'fit'在标签本身,而是该行仍然是在同一个地方:

var modules_info_panel = new Ext.TabPanel({ 
    activeTab: 0, 
    defaults:{autoScroll:true}, 
    items:[{ 
      title: 'Section 1', 
      layout: 'fit', 
      html: 'test' 
     },{ 
      title: 'Section 2', 
      layout: 'fit', 
      html: 'test' 
     },{ 
      title: 'Section 3', 
      layout: 'fit', 
      html: 'test' 
     }] 
}); 
+0

对此深感抱歉,我更新了我与布局的正确位置的响应:“适应” – McStretch 2010-12-02 15:25:05

回答

2

更正:

对不起爱德华我错了,你想要layout: 'fit'您的区域内容面板。更新的代码更改如下。

你最初的想法是使用layout: 'fit'是正确的,但你有它在错误的位置。你需要以下内容:

var regionContent = new Ext.Panel({ 
    region  : 'center', 
    autoScroll : true, 
    layout  : 'fit', // added this line 
    items  : [] 
}); 
+0

我试过了就像你的代码一样,但它没有帮助,我将它添加到了我的所有选项卡(上面的代码),但它仍然没有效果。 – 2010-12-02 15:15:48

+0

现在已经工作了,谢谢 – 2010-12-02 16:01:11

2

看起来你是在一个边界内布局,你如何定义设置边界布局的面板?边界布局的中心区域通常应填充其他区域未保留的空间。我做了一个样本,看起来像你的布局:http://jsbin.com/ikazo3/6/edit

Border Layout文档:

  • 使用BorderLayout这必须有一个子项与 区域的所有容器:“中心”。 中心区域中的子项目始终将调整大小 以填充布局中其他区域未使用的剩余空间 。
  • 任何具有西或东区域的子项必须具有定义的宽度 (表示该区域应取 以上的 像素数的整数)。
  • 任何具有北部或南部地区的儿童项目必须具有已定义的高度 。
  • BorderLayout的区域在渲染时被固定,此后,其子组件可能不会被 删除或添加。要在BorderLayout中添加/删除 组件,请使用 将其包装为由 BorderLayout直接管理的其他 容器。如果区域是 是可折叠的,则直接由BorderLayout管理器 使用的容器 应该是Panel。在下面的例子 容器(一个Ext.Panel)是 加入到西部地区: