SmartGWT TreeGrid 的叶/子节点不显示用于展开它们的文件夹图标
我需要在使用文件夹的“+”号扩展树节点时获取树节点的子记录。如果任何特定节点没有子节点,“+”号应该消失。此要求与链接中的要求类似,
但有些情况下这不起作用我。仅父节点显示文件夹,子节点不默认为文件夹。下面是我正在使用的代码。我已经从上面的链接复制了代码。唯一的变化是用树节点替换数据源。
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(); }
“节点 1”和“节点 2”显示带有“+”号的文件夹,但“节点 3”和“节点 4”不显示提供展开它们的选项。
如果我遗漏了什么,请帮忙。
谢谢, 瓦姆西
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
默认情况下为每个节点使用 setIsFolder(true) 并为叶节点设置为 false 来解决此问题。如果有人需要示例代码,请告诉我。
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.
认为您可能需要使用“getCanDropOnLeaves(true)”
TreeGrid 的 API 链接
think you may need to use "getCanDropOnLeaves(true)"
API Link for TreeGrid