1. #1
    Sencha Premium Member
    Join Date
    Apr 2008
    Posts
    27
    Vote Rating
    0
    smartin is on a distinguished road

      0  

    Question Answered: Grid - autoresize with BorderLayoutContainer

    Answered: Grid - autoresize with BorderLayoutContainer


    Hi,

    I'm using a BorderLayoutContainer which has a Grid in its CenterPanel (ContentPanel component). When I'm collapsing my westPanel the centerPanel expands (as expected) but my Grid does NOT ...

    What is the best way to achieve this autoresize/autoexpand functionality on a grid?

    Thanks.

  2. Thanks for the additional information, this will hopefully help to refine my suggestions, but without a test case to reproduce, there are still a few possibilities.

    Using a VerticalLC should *not* be a problem in this case, but I was overly cautious in my statement:
    * The Grid is directly added to the ContentPanel (not wrapped in something that would break the layout chain, as above)
    A VLC does not always qualify as a class that will 'break the layout chain' - if it is doing so, it is likely misconfigured. When adding a child to the VerticalLayoutContainer, it needs a VerticalLayoutData instance to specify how that child should be sized as the vlc changes. The values in this layout data type fall into three basic categories - -1 to measure the widget being added, 0.0-1.0 to indicate a percentage of the available space, and greater than 1 to specify a specific pixel value. In a case where you want the widget to resize, neither -1 nor greater than 1 make sense, as both will leave the widget at some already set value, and won't assign it the remaining space as that space changes. You almost certainly want some percentage value, and depending on the siblings of the Grid (i.e. the other children of the VLC), likely 1.0,1.0.

    If you are already correctly setting values on this, likely some other assumption I posted is being stretched/broken. Note that like the one I quoted above, stretching and breaking isn't necessarily a problem, but it does indicate at least that more information is required to help.

    Several guides that may help to shed more light on these topics:

  3. #2
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,734
    Vote Rating
    90
    Answers
    109
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    It is hard to say without seeing the setup/code, but with these assumptions, it should be working:
    * BorderLayoutContainer gets a size (either explicitly, or from a parent)
    * ContentPanel is added directly (not wrapped in something that will break the layout chain) - it is in the center region, right? setWidget or setCenterWidget *
    * ContentPanel.setResize(false) is *not* called (which would explicitly tell the panel not to resize its child)
    * The Grid is directly added to the ContentPanel (not wrapped in something that would break the layout chain, as above)

    And finally, is the issue that the Grid isn't changing at all, or that the columns aren't growing to fill the space? The above steps assume the former - the latter is usually because either no column is set to expand, or the gridview isn't set to forcefit=true.

  4. #3
    Sencha Premium Member
    Join Date
    Apr 2008
    Posts
    27
    Vote Rating
    0
    smartin is on a distinguished road

      0  

    Default


    Thanks for the answer/explanations. I managed to "solve" the problem if I add the grid directly to the centerPanel. I said "solve" because this is not my goal.
    What I'm trying to accomplish is to add the grid to a VerticalLayoutContainer (or any other panel that will expand itself with the centerPanel), which is then added to the centerPanel. Please note that with other components (like TextField for example) this is working fine: the verticalLayoutContainer does expand when the centerPanel gets more space and its components/children are also expanding. With the grid this is not working though...the grid will keep its initial size

    So i guess i have to use some listeners for the expand/collapse events and set the grid width manually if I want to accomplish my goal (as stated above).

    Is all this correct?

  5. #4
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,734
    Vote Rating
    90
    Answers
    109
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    Thanks for the additional information, this will hopefully help to refine my suggestions, but without a test case to reproduce, there are still a few possibilities.

    Using a VerticalLC should *not* be a problem in this case, but I was overly cautious in my statement:
    * The Grid is directly added to the ContentPanel (not wrapped in something that would break the layout chain, as above)
    A VLC does not always qualify as a class that will 'break the layout chain' - if it is doing so, it is likely misconfigured. When adding a child to the VerticalLayoutContainer, it needs a VerticalLayoutData instance to specify how that child should be sized as the vlc changes. The values in this layout data type fall into three basic categories - -1 to measure the widget being added, 0.0-1.0 to indicate a percentage of the available space, and greater than 1 to specify a specific pixel value. In a case where you want the widget to resize, neither -1 nor greater than 1 make sense, as both will leave the widget at some already set value, and won't assign it the remaining space as that space changes. You almost certainly want some percentage value, and depending on the siblings of the Grid (i.e. the other children of the VLC), likely 1.0,1.0.

    If you are already correctly setting values on this, likely some other assumption I posted is being stretched/broken. Note that like the one I quoted above, stretching and breaking isn't necessarily a problem, but it does indicate at least that more information is required to help.

    Several guides that may help to shed more light on these topics:

  6. #5
    Sencha Premium Member
    Join Date
    Apr 2008
    Posts
    27
    Vote Rating
    0
    smartin is on a distinguished road

      0  

    Lightbulb


    Colin,

    Thanks a lot for the prompt response!

    I managed to make it work - I was not setting the VerticalLayoutData with width of 1 (100% percentage, as you also explained) for one of the VerticalLayoutContainers I was using. When you mentioned this aspect I immediately realized where the problem was and fixed it.
    Kinda of rookie mistake - I guess I'm not yet fully accustomed with GXT layouts but I'm getting there

    Thanks again

  7. #6
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,734
    Vote Rating
    90
    Answers
    109
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    We're working on those guides to try to help make that learning curve more manageable, but a sufficiently powerful system that is compatible with the GWT HasWidgets or HasOneWidget is also going to necessarily be complex. We welcome any feedback you might have on those guides, as well as additional topics you think might be helpful.

Thread Participants: 1

Tags for this Thread