Results 1 to 5 of 5

Thread: [2.0.1] Height of component with scrollbar

  1. #1
    Sencha User
    Join Date
    Sep 2009
    Posts
    6
    Vote Rating
    0
      0  

    Question [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

  2. #2
    Ext User
    Join Date
    Sep 2008
    Location
    Germany
    Posts
    961
    Vote Rating
    1
      0  

    Default

    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

  3. #3
    Sencha User
    Join Date
    Sep 2009
    Posts
    6
    Vote Rating
    0
      0  

    Default

    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.

  4. #4
    Ext User
    Join Date
    Sep 2008
    Location
    Germany
    Posts
    961
    Vote Rating
    1
      0  

    Default

    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

  5. #5
    Sencha User
    Join Date
    Sep 2009
    Posts
    6
    Vote Rating
    0
      0  

    Thumbs up

    I was a bit hasty with my previous comment. mainBody is protected, so subclassing the TreeGridView worked.

    Code:
    class MyView extends TreeGridView {
    
            int getHeightDelta() {
    
                int viewHeight = scroller.getHeight();
                int bodyHeight = mainBody.getHeight();
                int headerHeight = innerHd.getHeight();
                return bodyHeight + headerHeight - viewHeight;
    
            }
    
        }
    with
    Code:
    _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);
                    }
                }
            });
    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 charm

    Thanks again for the help.
    /Klaus

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •