I a using GWT 2.3.In which I am using import com.google.gwt.user.client.ui.Tree. I want to show tree expanded always.For that I did below code for every tree item
treeItem.setState(true);
But it is not working.I am not getting how to expand tree. Please help me out.Thanks in advance
Do you expand the tree before you add child items to it? In that case he doesn't get expanded.
Here is an example which works for me:
private Tree createTree() {
// Create a Tree
TreeItem root = new TreeItem("root");
root.addItem("item0");
root.addItem("item1");
root.addItem("item2");
TreeItem childwithsubchilder = new TreeItem("subitmes");
childwithsubchilder.addItem("item0");
childwithsubchilder.addItem("item1");
childwithsubchilder.addItem("item2");
root.addItem(childwithsubchilder);
// expand the element
root.setState(true);
Tree t = new Tree();
t.addItem(root);
return t;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With