PDA

View Full Version : BorderLayout : Panel collapsed by default and programatically



seb2nim
4 Sep 2008, 4:33 AM
From : How to resize a BorderLayout Region programatically :


Seconded. We'd like to know how to collapse the regoin in code. This is useful for preview panes etc.



You this:


ContentPanel west = new ContentPanel();
west.getState().put("collapsed", true);


Sorry Darrel solution you suggest does not work.

It seems calling getState() just after constructor does not return the same object reference as when called within BorderLayout.onLayout().

Something i dond understand in initState() method from Component.

The only way i can set a panel initially collaped is to override Component 's initState() method :


protected void initState() {
super.initState();
getState().put("collapsed", true);
}But no way to programmatically/dynamically collapse or expand the panel after that (i mean using for example a 'toggle' button).

Can you be more precise ?

tbuckel
23 Sep 2008, 8:25 PM
From my understanding, you'd have to call

BorderLayout.onCollapse(ContentPanel panel);
which, unfortunately, is private. The solution I can think of, is this kind of hack (legal?):
Copy BorderLayout's source and make the methods you need public. Of course, this is pretty high in maintenance. :(

I generally found GXT pretty hard to customise, it's not designed for extension at all. Too many fields and methods are private, no factory methods for subordinate components, and if so they refer to other private methods...

Hope this helps
Thomas

villemustonen
9 Oct 2008, 4:23 AM
Has anyone found a solution to this? For me it is rather important that I could programmatically collapse the panel when needed.

LINEMAN78
9 Oct 2008, 9:17 AM
ContentPanels have .collapse() and .expand() functions, although I have not got this to work.

darrellmeyer
9 Oct 2008, 5:01 PM
See http://extjs.com/forum/showthread.php?p=236451#post236451.