为了获得ExtJS面板的高度,我挣扎着挣扎,唯一的原因是我可以认为它的区别在于它将面板定义为边框区域,因为我已经否则没有这个问题(也许我需要向他们报告一个错误)。我将从一些代码开始,这些代码演示我如何获得高度,结果展示了什么是高度,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());
}
},
我initally鼓励,我可能有一对夫妇的其他方法来获得高度,通过DOM节点,或通过componentLayout.lastComponentSize但这些都不是为Javascript访问代码,只有铬控制台。我最后的尝试将是解析返回的dom字符串,但这是一个可怕的黑客攻击。建议感激;在console.log结果下方是我的视图配置的相关部分。
的console.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>'
}]
},{
减哈克解决方法:因为你正在寻找的高度,-west-面板,怎么样'this.ownerCt.el.getHeight上(真);'? – Alex