How to expand tree in gwt?
Asked Answered
C

1

10

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

Cerous answered 7/9, 2011 at 7:40 Comment(0)
E
10

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;
}
Erdah answered 7/9, 2011 at 10:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.