Search code examples
iconsdirectorysmartgwtexpandtreegrid

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


Solution

  • 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.