PDA

View Full Version : [FIXED] [RC2] TreePanel not appearing after TreeStore.removeAll()



Cputerace
1 Jul 2009, 11:38 AM
I have boiled our code down to the following prototype which displays the issue we are having. When we initially populate a treestore, it displays fine (press populate). When we clear the screen (press clear) then subsequently populate the treestore again (press populate), the space for each of the items is there, but the items are not visible. You can mouse over the positions where they should be showing and it will grey out the line as if they are there.


package com.mycompany.gwtprototype.client;

import com.extjs.gxt.ui.client.data.BaseModelData;
import com.extjs.gxt.ui.client.data.BaseTreeModel;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.store.TreeStore;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.TabItem;
import com.extjs.gxt.ui.client.widget.TabPanel;
import com.extjs.gxt.ui.client.widget.Viewport;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
import com.extjs.gxt.ui.client.widget.treepanel.TreePanel;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;

public class GwtPrototype implements EntryPoint {

private Viewport v = new Viewport();
private TreeStore<BaseModelData> ts = new TreeStore<BaseModelData>();
private TreePanel<BaseModelData> treePanel;
private ContentPanel mainCP = new ContentPanel();
LayoutContainer screen = new LayoutContainer();

public void onModuleLoad() {
RootPanel.get().add(v);
v.setHeight("100%");
v.setLayout(new FlowLayout());
Button clearScreen = new Button("Clear Screen");
clearScreen.addSelectionListener(new SelectionListener<ButtonEvent>(){
@Override
public void componentSelected(ButtonEvent ce)
{
clearScreen();
}});
Button populateScreen = new Button("Populate Screen");
populateScreen.addSelectionListener(new SelectionListener<ButtonEvent>(){
@Override
public void componentSelected(ButtonEvent ce)
{
populateScreen();
}});
v.add(mainCP);
v.add(clearScreen);
v.add(populateScreen);
v.layout();

treePanel = new TreePanel<BaseModelData>(ts);
treePanel.setDisplayProperty("name");
TabPanel tabPanel = new TabPanel();
TabItem tabItem = new TabItem("A Tab");
tabItem.add(treePanel);
tabPanel.add(tabItem);
screen.add(tabPanel);
}

protected void populateScreen()
{
ts.removeAll();
final BaseTreeModel root = new BaseTreeModel();
root.set("name", "another item");
final BaseTreeModel root2 = new BaseTreeModel();
root2.set("name", "another item");
final BaseTreeModel root3 = new BaseTreeModel();
root3.set("name", "another item");
ts.add(root, true);
ts.add(root2, true);
ts.add(root3, true);
mainCP.removeAll();
mainCP.add(screen);
mainCP.layout();
}

protected void clearScreen()
{
mainCP.removeAll();
}
}

Cputerace
6 Jul 2009, 11:24 AM
Any update on this? It is breaking our app.

sven
6 Jul 2009, 11:42 AM
Fixed in SVN