最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Ext JS Border layout: how to collapse a region programmatically? - Stack Overflow

programmeradmin0浏览0评论

I have a panel with "border" layout, having "center" and "north" region. I want to programmatically collapse the north region, and according to the forum the way to do that is:

container.layout.north.collapse();

However, container.layout is a string object thus container.layout.north giving me null object.

Does anyone have a 2 seconds pointer on how to get a handle to the correct layout object to call collapse() upon?

I have a panel with "border" layout, having "center" and "north" region. I want to programmatically collapse the north region, and according to the forum the way to do that is:

container.layout.north.collapse();

However, container.layout is a string object thus container.layout.north giving me null object.

Does anyone have a 2 seconds pointer on how to get a handle to the correct layout object to call collapse() upon?

Share Improve this question asked May 11, 2011 at 6:59 bungrudibungrudi 1,4171 gold badge17 silver badges25 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 1

The cheapest way would be to get hold of the panel you need by calling Ext.getCmp(). For you the container.layout is undefined because it not an object of Ext.Component. Set an Id for you border panel or any panel you need access to.

 var panel = Ext.getCmp('BorderPanelId');
 panel.layout.north.collapse();

Another way would be to use the north panel's Id. In that case you will:

 var panel = Ext.getCmp('NorthPanelId');
 panel.collapse();

Another way would be to make user of the ref system. Set the ref property for your panels. And if you have access to ponent's owner.. you can simple use the ref to reference the panel or other ponents.

In Extjs 4 you can do:

panel.getLayout().regions.north.collapse();

Then to reactivate the region:

panel.getLayout().regions.north.expand();

Using Ext JS 4 you can do:

container.down('[region=north]').collapse(); 

That's the easiest and remended way.

发布评论

评论列表(0)

  1. 暂无评论