Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to expand tree in gwt?

Tags:

gwt

gwt2

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

like image 477
Sanjay Jain Avatar asked Sep 07 '11 07:09

Sanjay Jain


1 Answers

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;
}
like image 150
Stefan Avatar answered Sep 18 '22 21:09

Stefan