View Full Version : Trouble with Grid

23 Jun 2009, 3:36 PM
I'm putting a Grid inside a LayoutContainer, like so:

public class GridWidget extends LayoutContainer {
public GridWidget(...) {
super(new FitLayout());
setSize(width, height);

ArrayList<ColumnConfig> configs = new ArrayList<ColumnConfig>();
for(String column : columns) {
ColumnConfig config = new ColumnConfig();

Grid<BaseModel> grid = new Grid<BaseModel>(store, new ColumnModel(configs));


My test data has 7 columns, 3 rows. Width and height for LayoutContainer is 350x150, so if I divide 350 by 7, colWidth should be 50. But when this is rendered on screen, the table does not take up to full width nor the full height of the LayoutContainer. Is there a way to calculate the appropriate column width and row height of the Grid so that it fits the preset size of LayoutContainer, or make LayoutContainer fit (shrink) to the table?

Also is there any function to calculate the preferable width of the column based on the data store? Or can grid auto size all the columns, etc.

Another thing I noticed is that eventually I set every column as resizable and sortable, the result doesn't appear so, some are not sortable (no icon), some doesn't do anything after dragging the cell border for resize. Didn't see any obvious difference between the columns where resize/sort did work and ones that didn't.

Thanks in advance.

NOTE: I'm using 2.0m1, please let me know if this is fixed/different in the newer version.

24 Jun 2009, 10:01 PM
Figured out 2/3 of the problems. The extra size was because somewhere else in my code I was resizing the container. The issue with some columns not having sort button and not resizable was because those columns had spaces in their ID. Still looking for a way to auto calculate the preferred column size, or if there is an auto-fit option. Thanks.