dav
25 May 2008, 2:02 PM
I am trying to use GXT 1.0 beta3 Table component and have noticed its strange behavior.
I created simple Table with three columns: "Alias", "Host", "Port" and when Render event occurs I fill this table with 5 items.
When my GWT application starts, the last (5-th) item renders but then disappears. You can see this on the attached animated gif.
I think this concern with loading splash <div> that hides after viewport is rendered.
For testing this I added to my app a Timer in the Render event listener. So, if the time of the timer schedule commensurable with the time of splash <div> hides time, the last item disappears after viewport is rendered. (for example: if tm.schedule(100); then item disappears, if tm.schedule(1000); everything is fine).
Initially table is sorted by first column. When I try to sort, for example, by second - first column header still marked as 'sorted' and you can see how table is sorted by two columns at the same time.
When I try to hide one column and then show it again table elements hide and show correctly, but when the header column was hidden it never could be shown again.Here is the code:
public class GxtDemo implements EntryPoint {
public void onModuleLoad() {
basicTableTest();
}
protected void basicTableTest() {
Viewport viewport = new Viewport();
viewport.setLayout(new CenterLayout());
ContentPanel cp = new ContentPanel(new FitLayout());
cp.setHeading("BasicTable test");
cp.setFrame(true);
cp.setWidth(400);
cp.setHeight(200);
final TableColumn columns[] = {
new TableColumn("ALIAS_ID", "Alias", 200),
new TableColumn("IPADDR_ID", "Host", 100),
new TableColumn("PORT_ID", "Port", 50),
};
TableColumnModel tcm = new TableColumnModel(columns);
final Table<RowSelectionModel> table = new Table<RowSelectionModel>(tcm);
table.setHorizontalScroll(true);
table.sort(0, Style.SortDir.ASC);
table.addListener(Events.Render, new Listener<ComponentEvent>() {
private Timer tm;
public void handleEvent(ComponentEvent be) {
tm = new Timer() {
public void run() {
fillTable(table);
}
};
tm.schedule(100);
}
});
cp.add(table);
viewport.add(cp);
RootPanel.get().add(viewport);
}
protected void fillTable(Table<RowSelectionModel> table) {
Object[][] serversData = {
new Object[] {"Alias 1", "192.168.10.1", "1114"},
new Object[] {"Alias 2", "192.168.10.2", "1113"},
new Object[] {"Alias 3", "192.168.10.3", "1112"},
new Object[] {"Alias 4", "192.168.10.4", "1111"},
new Object[] {"Alias 5", "192.168.10.5", "1110"},
};
for (Object[] data : serversData) {
TableItem ti = new TableItem(data);
table.add(ti);
}
}
}
I created simple Table with three columns: "Alias", "Host", "Port" and when Render event occurs I fill this table with 5 items.
When my GWT application starts, the last (5-th) item renders but then disappears. You can see this on the attached animated gif.
I think this concern with loading splash <div> that hides after viewport is rendered.
For testing this I added to my app a Timer in the Render event listener. So, if the time of the timer schedule commensurable with the time of splash <div> hides time, the last item disappears after viewport is rendered. (for example: if tm.schedule(100); then item disappears, if tm.schedule(1000); everything is fine).
Initially table is sorted by first column. When I try to sort, for example, by second - first column header still marked as 'sorted' and you can see how table is sorted by two columns at the same time.
When I try to hide one column and then show it again table elements hide and show correctly, but when the header column was hidden it never could be shown again.Here is the code:
public class GxtDemo implements EntryPoint {
public void onModuleLoad() {
basicTableTest();
}
protected void basicTableTest() {
Viewport viewport = new Viewport();
viewport.setLayout(new CenterLayout());
ContentPanel cp = new ContentPanel(new FitLayout());
cp.setHeading("BasicTable test");
cp.setFrame(true);
cp.setWidth(400);
cp.setHeight(200);
final TableColumn columns[] = {
new TableColumn("ALIAS_ID", "Alias", 200),
new TableColumn("IPADDR_ID", "Host", 100),
new TableColumn("PORT_ID", "Port", 50),
};
TableColumnModel tcm = new TableColumnModel(columns);
final Table<RowSelectionModel> table = new Table<RowSelectionModel>(tcm);
table.setHorizontalScroll(true);
table.sort(0, Style.SortDir.ASC);
table.addListener(Events.Render, new Listener<ComponentEvent>() {
private Timer tm;
public void handleEvent(ComponentEvent be) {
tm = new Timer() {
public void run() {
fillTable(table);
}
};
tm.schedule(100);
}
});
cp.add(table);
viewport.add(cp);
RootPanel.get().add(viewport);
}
protected void fillTable(Table<RowSelectionModel> table) {
Object[][] serversData = {
new Object[] {"Alias 1", "192.168.10.1", "1114"},
new Object[] {"Alias 2", "192.168.10.2", "1113"},
new Object[] {"Alias 3", "192.168.10.3", "1112"},
new Object[] {"Alias 4", "192.168.10.4", "1111"},
new Object[] {"Alias 5", "192.168.10.5", "1110"},
};
for (Object[] data : serversData) {
TableItem ti = new TableItem(data);
table.add(ti);
}
}
}