【发布时间】:2012-08-28 11:56:07
【问题描述】:
我在这里发现了 2 个类似的问题,但对我没有帮助,我的代码是:
var grid = Ext.create('Ext.grid.Panel', {
autoScroll: true,
// if set this to any numeric value, then everything works just good, but
// i was hoping that `ExtJS` already can detect browser window height, am i wrong ?
height: '100%',
title: 'Products',
store: store,
itemId: 'product_grid',
columns: [.. columns skipped ...],
plugins: [ rowEditing ],
dockedItems: [ ..addRow button here..]
});
var panel = Ext.create('Ext.panel.Panel', {
autoScroll: true,
items: [
{
xtype: 'productGrid'
}
]
});
Ext.create('Ext.container.Viewport', {
layout: 'fit',
items: panel
});
我需要填充整个浏览器窗口的可滚动网格,但此处的网格不会展开 在高度,所以如果网格有 0 行,那么它有 0 高度,当我按下“添加行”时,然后 添加的行看起来被滚动条遮住了,这看起来很难看。
此外,当网格包含的行数超出浏览器窗口的容量时,会出现页面滚动条(不是网格的滚动条!),这会滚动整个页面,因此按钮栏会滚动,这也是不受欢迎且丑陋的。
任何想法我的设置有什么问题。
更新:
终于修好了,中间面板也应该包含layout: 'fit'
【问题讨论】:
-
我尝试更改布局,但没有成功
-
当我动态添加行时,我想我应该调用类似 doLayout 的东西,但是在哪个组件上?
-
Ext.ComponentQuery.query返回一个组件数组。如果是通过 ID 访问单个组件,不妨直接使用Ext.getCmp获取。
标签: javascript extjs4