Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Auto Resize a HLayout after ListGrid re-drawn with AutoFitFieldWidths(true)

    rulesVLayout.addMembers(techGrid,rulesHLayout);SmartClient Version: SNAPSHOT_v11.1d_2017-01-31/PowerEdition Deployment (built 2017-01-31)

    This is a reasonably simply question, so hopefully you don't need example code.

    The Canvas has a single VLayout and single HLayout. The HLayout contains 3 IButtons, with 2 Layout spacers between the 3 buttons:

    rulesHLayout.addMembers(applyChangeBtn, hSpcr1, addNewBtn, hSpcr2, exitBtn);

    The VLayout simply contains a listgrid and the HLayout:

    rulesVLayout.addMembers(techGrid,rulesHLayout);

    The grid is defined with these features:

    techRulesWindow.setAutoSize(true);
    techRulesWindow.setLeft(100);
    techRulesWindow.setTop(75);
    techRulesWindow.setAnimateShowEffect(AnimationEffect.FADE);
    techRulesWindow.setAnimateShowTime(900);
    techGrid.setAutoFitFieldWidths(true);
    techGrid.setAutoFitData(Autofit.BOTH);
    techGrid.setAutoWidth();
    techGrid.setHeight(600);
    techGrid.setAutoFetchData(true);

    When the window opens, the HLayout is drawn with a relatively small size, the buttons of the rulesHLayout get drawn and spaced over that small width - but following correctly the rule to allow enough space to draw the icons and allow for their title overflows - so it looks correct but is of a small width.

    The grid then fetches it's data an re-draws to fit the data and headings to a much WIDER correctly drawn grid, with the AutoFit function drawing it correctly.

    However the HLayout and its buttons do not get re-drawn to match the grid size, and its layout looks compressed against the grid. If I resize the window the HLayout then redraws and spaces the button out appropriately, one to the left, one in the middle and the last on the right.

    Is there some 'automatic' way to get the HLayout to resize when the gird auto-fits, or do I have to add a fetchData Handler to the grid, and mark the window for re-draw when it is called back?


    #2
    The issue here is that we generally can't have a layout's sizing algorithm be driven by the overflowed size of one of its members. The layout (in this case the VLayout contianing the grid and the HLayout) has a known, specified width and sizes the HLayout to fit it. When the grid fetches data, it exceeds that width due to the auto-fit settings on the grid, and the VLayout will expand to fit it, but the specified size of the VLayout won't change and as such it won't attempt to resize the other members to be wider. This is basically a requirement - we can't have a Layout's sizing algorithm be both driving the size of its members and being driven by their sizes.
    When you explicitly resize the Window you are essentially causing the HLayout's specified size to increase (as it'll fit to the window). Now its larger specified size will cause the buttons to expand to accomodate the available space.

    For your usage, you may be able to get the results you need by reacting to a fetchData callback, or the dataArrived notification on the grid or similar, as you suggest.
    If you find you can't get the behavior you need, let us know (and in this case share a small test case so we can see things in action) and we'll take a look.

    Regards
    Isomorphic Software

    Comment

    Working...
    X