AsyncCallback creation of Accordion contents not displayed
It seems that when I populate the contents of an Accordion panel they are not displayed until I do a window resize.
eg:
I load a set of categories from a database and create a Panel for each of them.
The panels are added to the Accordion window.
Each panel (aka category) contains a grid of items.
The grid is not displayed unless I do a Window resize.
If I hard-code the call of the function that fills the grid, it displays ok.
If I call the function that fills the grid from the onSuccess function of a AsyncCallback the grid is not displayed.
I have tried overriding the onRender, onClick and other events.
I have also tried changing the width of the grid, making the store listen for changes. No good.
I have also tried using a tree instead of a grid, same result.
I then tried putting a button in the panel, same result - not displayed until I do a window resize.
I'm using GWT 1.5.3, gxt-1.2.1
Any help is greatly appreciated.
Sean
Code:
public class NichePanel extends ContentPanel {
AManagerServiceAsync aManagerService;
String previousCategory;
Grid<NicheModel> selectedGrid;
public NichePanel() {
setHeading("Niches");
setIconStyle("icon-niches");
setLayout(new AccordionLayout());
buildUI();
loadCategories();
}
...
private void loadCategories() {
//if (1 == 1) {
// this works just fine
//loadNiche(new NicheModel(1L, "first", "cat one", Status.RUNNING));
//return;
//}
// this displays empty panels until the window is resized
aManagerService = AManagerService.App.getInstance();
aManagerService.getNiches(new AsyncCallback<List<NicheModel>>() {
public void onFailure(Throwable caught) {
ClientLogger.logWarn(this, caught.toString());
}
public void onSuccess(List<NicheModel> nicheList) {
Collections.sort(nicheList, new NicheModelComparator());
for (NicheModel niche : nicheList)
loadNiche(niche);
}
});
}
private void loadNiche(NicheModel niche) {
if (!niche.get(Column.CATEGORY).equals(previousCategory)) {
previousCategory = (String) niche.get(Column.CATEGORY);
ContentPanel cp = new ContentPanel();
cp.setHeading((String) niche.get(Column.CATEGORY));
cp.setLayout(new FitLayout());
selectedGrid = createGrid();
cp.add(selectedGrid);
cp.show();
add(cp);
}
selectedGrid.getStore().insert(niche, 0);
selectedGrid.getStore().commitChanges();
}