获取用作边框区域的 ExtJS 面板的高度
Getting height of ExtJS panel used as border region
我正在努力获得 ExtJS 面板的高度,我认为它有什么不同的唯一原因是它是定义为边界区域的面板,因为我没有遇到这个问题否则(也许我需要向他们报告错误)。 我将从一些代码开始,演示我如何尝试获取高度,结果演示高度到底是什么,ExtJS说它是什么,以及使用不同布局的面板(边框区域内的面板之一)如何不是问题:
'cmBuildTab #cmProductExplorer': {
afterrender: function(productExplorer) {
var domNode = Ext.getDom(productExplorer.el),
savedSearchesPanel = productExplorer.down('#savedSearchesPanel');
console.log('productExplorer.getHeight(): ' + productExplorer.getHeight());
console.log(productExplorer.componentLayout);
console.log(productExplorer.componentLayout.lastComponentSize);
console.log(domNode);
console.log('domNode.style.height: ' + domNode.style.height);
console.log('savedSearchesPanel.getHeight(): ' + savedSearchesPanel.getHeight());
}
},
我最初受到鼓舞,我可能有几个替代方法来获得高度,通过dom节点,或通过componentLayout.lastComponentSize,但Javascript代码都无法访问这些方法,只有chrome控制台可以访问。 然后我的最后一次尝试是解析返回的 dom 字符串,但这是一个可怕的黑客。 感谢建议;在控制台下方.log结果是我的视图配置的相关部分。
控制台.log结果:
productExplorer.getHeight(): 2
Ext.Class.newClass
autoSized: Object
borders: Object
calculateDockBoxes_running: false
childrenChanged: true
frameSize: Object
id: "dock-1155"
info: Object
initialized: true
initializedBorders: true
lastComponentSize: Object
height: 787
width: 254
__proto__: Object
layoutBusy: false
layoutCancelled: false
onLayout_running: false
owner: Ext.Class.newClass
previousComponentSize: undefined
targetInfo: Object
__proto__: Class.registerPreprocessor.prototype
undefined
<div id="panel-1049" class="x-panel x-box-item x-panel-default" role="presentation" aria-labelledby="component-1198" style="margin: 0px; width: 254px; height: 787px; left: 0px; top: 0px; ">…</div>
domNode.style.height:
savedSearchesPanel.getHeight(): 151
视图配置(部分):
},{
region: 'west',
collapsible: true,
title: 'Product Explorer',
itemId: 'cmProductExplorer',
split: true,
width: '20%',
minWidth: 100,
layout: {
type: 'vbox',
pack : 'start',
},
items: [{
collapsible: true,
width: '100%',
border: false,
title: 'Search',
itemId: 'savedSearchesPanel',
items: [{
border: false,
xtype: 'cmSearchTermAccordionPanel'
},{
border: false,
margin: '5 20 0 20',
html: 'Saved Searches:<hr>'
}]
},{
afterrender
不是要用于确定组件高度的事件,它会在元素渲染时触发,而不是在调整元素大小后触发。 如果您使用的是 4.1,则可以使用 boxready
事件,该事件仅在容器的初始大小 http://docs.sencha.com/ext-js/4-1/#!/api/Ext.AbstractComponent-event-boxready 触发。 如果没有,您可以使用 afterlayout
事件来确定大小,但该事件会触发每个布局。
此外,仅供参考,作为百分比的宽度没有记录为 4.0 中支持,我已经看到它们有效并且我看到它们失败了。
这是我从视口示例中劫持的一些代码,这要归功于法院裁定这是可以的。
4.1
Ext.create('Ext.container.Viewport', {
layout: 'border',
items: [{
region: 'north',
html: '<h1 class="x-panel-header">Page Title</h1>',
border: false,
margins: '0 0 5 0'
}, {
region: 'west',
collapsible: true,
title: 'Navigation',
width: 150,
//ADD LISTENERS
listeners: {
afterrender:function(){console.log( 'afterrender ' +this.getHeight())},
boxready:function(){console.log( 'boxready ' +this.getHeight())}
}
// could use a TreePanel or AccordionLayout for navigational items
}, {
region: 'south',
title: 'South Panel',
collapsible: true,
html: 'Information goes here',
split: true,
height: 100,
minHeight: 100
}, {
region: 'east',
title: 'East Panel',
collapsible: true,
split: true,
width: 150
}, {
region: 'center',
xtype: 'tabpanel', // TabPanel itself has no title
activeTab: 0, // First tab active by default
items: {
title: 'Default Tab',
html: 'The first tab''s content. Others may be added dynamically'
}
}]
});
输出:
afterrender 2
boxready 276
相关文章:
- electronic BrowserWindow的最小高度和宽度在hide()show()方法之后不起作用
- ExtJS 5用程序点击actioncolumn gridview
- ExtJS——在展开/折叠时调整面板高度
- 分析高度属性时出现意外值{{specs.height}}.index.html
- ExtJS使网格高度达到100%
- ExtJS 4.2.1-具有动态高度的边界布局
- 如何在调用 setSource() 函数后重绘或更新 extjs 网格的宽度/高度
- 在 extJS 中设置边框布局的最小高度
- 获取用作边框区域的 ExtJS 面板的高度
- 自动调整Extjs 4.2.1视口内的高度
- extJs(设置高度和宽度)(以百分比表示)
- ExtJS门户布局问题(内部元素的自动高度/宽度)
- ExtJS:100%高度面板导致溢出
- ExtJS GridPanel基于行计数的动态高度
- ExtJs,从不同版本的iframe创建窗口,正确设置高度
- EXTJS:如何在没有高度的空面板上添加dockedItems之间的空间
- 带有边界布局和动态高度子节点的ExtJS容器
- 更改EXTjs的ext.tab.Tab组件的高度或添加填充
- 我怎么能使一个窗口在100%的高度和宽度与ExtJs
- 使用ExtJS-4X或javascript获取视口高度