Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Leaf/Child Nodes of a SmartGWT TreeGrid do not show Folder icon to expand them

I have a requirement to fetch the child records of a tree node on expanding it using the "+" sign of the folder. If any particular node doesnt have children the "+" sign should vanish. This requirement is similar to the one in link

But some how this doesn't work for me. Only parent node shows a folder and the child nodes do not default to a Folder. Below is the code I am using. I have copied the code from the above link. The only change being replacing the data source with tree nodes.

public void onModuleLoad()
    {
        Tree adminTree = new Tree();
        adminTree.setID("adminTreeId");
        adminTree.setModelType(TreeModelType.PARENT);
        adminTree.setRootValue("/");
        adminTree.setAutoOpenRoot(true);

        TreeGrid adminTreeGrid = new TreeGrid();  
        adminTreeGrid.setWidth(500);  
        adminTreeGrid.setHeight(400);  
        adminTreeGrid.setShowOpenIcons(false);  
        adminTreeGrid.setShowDropIcons(false);  
        //adminTreeGrid.setClosedIconSuffix("");  
        adminTreeGrid.setAutoFetchData(true);  
        adminTreeGrid.setData(adminTree);  

        TreeNode treeNode1 = new TreeNode();
        treeNode1.setTitle("Node 1");
        treeNode1.setID("node1");

        TreeNode treeNode2 = new TreeNode();
        treeNode2.setTitle("Node 2");
        treeNode2.setID("node2");

        TreeNode treeNode3 = new TreeNode();
        treeNode3.setTitle("Node 3");
        treeNode3.setID("node3");

        TreeNode treeNode4 = new TreeNode();
        treeNode4.setTitle("Node 4");
        treeNode4.setID("node4");

        adminTree.add(treeNode1, "/");
        adminTree.add(treeNode2, "/");
        adminTree.add(treeNode3, treeNode1);
        adminTree.add(treeNode4, treeNode2);

        adminTreeGrid.draw();       
    }

"Node 1" and "Node 2" are showing a folder with a "+" sign but "Node 3" and "Node 4" do not show give an option to expand them.

Please help out if I am missing something.

Thanks, Vamsi

like image 321
user736179 Avatar asked May 19 '11 07:05

user736179


2 Answers

Solved this using setIsFolder(true) by default for each node and making it false for leaf nodes. Let me know if anyone needs sample code.

like image 114
user736179 Avatar answered Dec 17 '22 22:12

user736179


think you may need to use "getCanDropOnLeaves(true)"

API Link for TreeGrid

like image 25
Holograham Avatar answered Dec 17 '22 21:12

Holograham