extjs 面板在窗口大小调整时调整大小
我有一个带有“表单”布局的面板,其中包含几个按钮。现在我想启用此面板根据窗口大小调整大小。我怎样才能完成这件事?
谢谢。
I have a panel with a "form" layout, containing several buttons. now I want to enable this panel resize according to window resizing. How can I get this done?
thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
假设您有一个名为“panel”的面板,其中内置了一些自动调整大小的功能(例如
height: "100%"
)。否则,窗口的新宽度和高度将传递到传递给onWindowResize()
的匿名函数中。Assuming you have a Panel named 'panel' with some automatic sizing built in (e.g.
height: "100%"
). Otherwise, the new width and height of the window are passed into the anonymous function passed toonWindowResize()
.正如 @deniztt 所写,您应该订阅 Windows 调整大小事件上的 EventManager 类。
它可以是这样的:
其中面板是对您的面板的引用
您可以 在此处阅读。
As wrote @deniztt you should subscribe to EventManager class onWindows Resize Event.
It can be something like this:
Where panel is reference to your panel
You can read about it here.
您可以通过设置“可调整大小”配置选项来调整面板大小,请参阅各种选项的文档:http://dev.sencha.com/deploy/ext-4.0.0/docs/api/Ext.panel.Panel.html。
至于表单组件如何交互,如果您想使用表单布局或切换到具有各种弹性设置的水平盒/垂直盒类型设置,则需要设置锚点。
You can make the panel resizable by setting the 'resizable' config option, see the docs for the various options: http://dev.sencha.com/deploy/ext-4.0.0/docs/api/Ext.panel.Panel.html.
As far as how the form components interact you'll need to set anchor's if you want to use a form layout or switch to an hbox/vbox type of set-up with various flex settings.
您可以设置窗口的大小,并将子面板的
autoHeight
和autoWidth
属性设置为 true。另一种方法是捕获窗口的
resize
事件,并根据新的大小值调整子面板的大小。You can set the size for window and set the child panel's
autoHeight
andautoWidth
attributes true.Another way is catching the
resize
event of the window and resize the child panel according to the new size values.感谢 Gegory 和 Joseph 提供的 EventManager 解决方案。我对此解决方案做了一些小的更改,用 DIV 替换 getBody() 并设置图表(或任何其他组件)的初始宽度/高度:
autoWidth 和 autoHeight 似乎对我不起作用(Ext- JS 4.2.1)。
Thanks to Gegory and Joseph for the EventManager solution. I've done some minor changes to this solution, replacing the getBody() with a DIV and setting an initial width/height of my chart (or any other component):
autoWidth and autoHeight don't seem to work for me (Ext-JS 4.2.1).