PDA

View Full Version : Grid doesn't show any rows if column headers are set



swilber1579
7 Feb 2012, 10:53 AM
Using the code below, I see a table with column headers, but no rows. If I comment out the first two ColumnConfigs and uncomment the others, I get a table with rows but no headers. Any ideas?


public class Gxt_projects implements EntryPoint {
@Override
public void onModuleLoad() {
List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
columns.add(new ColumnConfig("col1", "Column 1", 200));
columns.add(new ColumnConfig("col2", "Column 2", 200));
// columns.add(new ColumnConfig("col1", 200));
// columns.add(new ColumnConfig("col2", 200));
ColumnModel cm = new ColumnModel(columns);
ListStore<Entry> store = new ListStore<Entry>();
store.add(new Entry("asdf", "foo"));
store.add(new Entry("djdj", "djdj"));
Grid<Entry> grid = new Grid<Entry>(store, cm);
RootPanel.get().add(grid);
}

public static class Entry extends BaseModel {
public Entry(String col1, String col2) {
set("col1", col1);
set("col2", col2);
}
}
}

sven
7 Feb 2012, 10:58 AM
Have you tried to give a size to the grid?

swilber1579
7 Feb 2012, 11:01 AM
Thanks for the idea, but I just tried that with no change in behavior. Btw, this is GXT 2.2.5 on GWT 2.4.0.

sven
7 Feb 2012, 11:08 AM
public class Gxt_projects implements EntryPoint {

public void onModuleLoad() {
List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
columns.add(new ColumnConfig("col1", "Column 1", 200));
columns.add(new ColumnConfig("col2", "Column 2", 200));
// columns.add(new ColumnConfig("col1", 200));
// columns.add(new ColumnConfig("col2", 200));
ColumnModel cm = new ColumnModel(columns);
ListStore<Entry> store = new ListStore<Entry>();
store.add(new Entry("asdf", "foo"));
store.add(new Entry("djdj", "djdj"));
Grid<Entry> grid = new Grid<Entry>(store, cm);
grid.setSize(400, 200);
RootPanel.get().add(grid);
}


}

Works fine for me.

swilber1579
7 Feb 2012, 11:11 AM
Thanks that worked. I had tried setWidth() not setSize().