-
30 Sep 2009 6:42 AM #1
[2.0.1] Height of component with scrollbar
[2.0.1] Height of component with scrollbar
Hi All
I have a TreeGrid in a LayoutContainer with a default height.
When I start expanding the nodes in the treeGrid I want to resize the container to avoid scrollbars.
I know I can use _tree.setAutoHeight(true); but then my container is 0px high when it renders because the data for the tree is loaded async. And it looks really stupid in a portal where all portlets have the same height to begin with.
If anyone could tell me how to get the actual size of the TreeGrid, both the visible and the scrolled-away part, I could resize my container in response to Events.Expand.
/Klaus
-
30 Sep 2009 7:04 AM #2
if you look into Grid.java you see at some places mainBody.getHeight();
for example also in calculateVBar()
maybe there you get some hints how to calculate this.This forum needs your help: you got hints from the community and now you have fixed your code? dont just reply with "now its fixed" or "i found the error"! please take the time to post also an detailed answer with the working code.
GreaseMonkey Script for a GXT-only Forum: it hides ExtJs here: New Posts • Search Results • Advanced Search form • Category overview http://www.extjs.com/forum/showthrea...041#post410041
-
30 Sep 2009 7:50 AM #3
Thanks for the hint. However mainBody is private and not accisable in any way.
I remember doing some frame resizing a while back, and there the idea was to add 5px to the size of the frame,until the scrollbar disapeared. Guess the same approace would work, it I knew how to detect when the GridView displays its scrollbar - any suggestions.
-
30 Sep 2009 8:01 AM #4
it fires this event after the refresh:
fireEvent(Events.Refresh);This forum needs your help: you got hints from the community and now you have fixed your code? dont just reply with "now its fixed" or "i found the error"! please take the time to post also an detailed answer with the working code.
GreaseMonkey Script for a GXT-only Forum: it hides ExtJs here: New Posts • Search Results • Advanced Search form • Category overview http://www.extjs.com/forum/showthrea...041#post410041
-
30 Sep 2009 8:26 AM #5
I was a bit hasty with my previous comment. mainBody is protected, so subclassing the TreeGridView worked.
withCode:class MyView extends TreeGridView { int getHeightDelta() { int viewHeight = scroller.getHeight(); int bodyHeight = mainBody.getHeight(); int headerHeight = innerHd.getHeight(); return bodyHeight + headerHeight - viewHeight; } }
When the getHeightDelta is positive I re-size the portlet containing the TreeGrid. I may need some adjusting for border etc, but otherwise it works like a charmCode:_tree.addListener(Events.Expand, new Listener<TreeGridEvent>() { public void handleEvent(TreeGridEvent be) { MyView view = (MyView) _tree.getTreeView(); int delta = view.getHeightDelta(); if (delta > 0 ) { setHeight(getHeight() + delta); } } });
Thanks again for the help.
/Klaus


Reply With Quote