PDA

View Full Version : Auto height grids?



Foxzorz
19 Oct 2015, 6:17 AM
Hello,

After many many hours I have been unable to get consistent auto-height grids implemented using GXT 3.1.

We are writing a data input system that uses several grids stacked on top of each other vertically inside a main window which is scrollable, thus the scrollbars in the grids are not required.

The only way I have been able to reliably handle this is to manually calculate what we think the height of a grid might be based on the number of records we think it might have... I found another solution online for 'auto height' grids but these require forceLayout() to be called on parent layouts all over the place and it makes things appear clunky.

Has anyone managed to implement a nice auto-height grid that just works? Having a large 'clunk' as the page invalidates itself isn't really the crisp user experience I'm trying to sell my boss with GXT :D

rankinc
2 Nov 2015, 6:25 AM
Your idea of an "auto height grid" may be different from mine, but here is what worked for me when my grids were misbehaving in GXT 2.2.5:


public class AutoHeightGrid<M> extends Grid<M> {

public AutoHeightGrid(ListStore<M> store, ColumnModel cm) {
super(store, cm);
}

@Override
protected void onResize(int width, int height) {
super.onResize(width, height);
el().setStyleAttribute("height", "auto");
}

};
It is literally an "auto height grid" in the sense that it applies CSS style "height: auto" to the grid after it resizes :).