开发者

How to expand tree in gwt?

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.Tha开发者_如何学Gonks 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;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜