I am creating a GWT tree and I would like it to initially display with open nodes. Take the standard tree example from GWT javadocs :
public class TreeExample implements EntryPoint {
public void onModuleLoad() {
TreeItem root = new TreeItem("root");
root.addItem("item0");
root.addItem("item1");
root.addItem("item2");
TreeItem item = new TreeItem(new CheckBox("item3"));
root.addItem(item);
Tree t = new Tree();
t.addItem(root);
RootPanel.get().add(t);
}
}
I want it to initially display as:
root
item0
item1
item2
item3
Now I thought it was as simple as setting the state TreeItemI want to open by calling setState(true): javadoc for setStatesays: "Sets whether the children of this element are displayed." However, if you add, for example,
root.setState(true);
to the example above, I am not getting the expected effect. Apparently, nothing changes when I do root.setState(true);or root.setState(false);: the tree is always displayed with the nodes closed.
How do I get the desired behavior?