PDA

View Full Version : Problem expanding all tree items, only the first one shows as expanded



connysvensson
25 Jun 2008, 1:32 AM
I have a tree that I want to be completely expanded when it's rendered. I set the expanded attribute to true for all TreeItems when I render them but only the first one is expanded, but all show the expanded arrow next to the icon. So it seems like it's correctly reading the expanded attribute but there is some rendering bug. I see the same problem in the AccordionLayout demo in the explorer.
This is my code:


private void renderNavigation() {
tree = new Tree();
tree.addListener(Events.SelectionChange, new Listener<TreeEvent>() {
public void handleEvent(TreeEvent ev) {
setActiveModule(tree.getSelectedItem().getItemId());
}
});
TreeItem treeNode = new TreeItem();
for (ModuleCategory category : ModuleFactory.getCategories()) {
treeNode = new TreeItem(category.getName());
tree.getRootItem().add(treeNode);
renderTreeNode(category, treeNode);
}
menuPanel.add(tree);
}

private TreeItem renderTreeNode(ModuleCategory category, TreeItem treeNode) {
treeNode.setExpanded(true);
for (ModuleCategory subCategory : category.getCategories()) {
treeNode.add(renderTreeNode(subCategory, new TreeItem(category.getName())));
}
for (ModuleHolder module : category.getModules()) {
TreeItem item = new TreeItem(module.getName());
item.setItemId(module.getPath());
if (module.getIconStyle() != null)
item.setIconStyle(module.getIconStyle());
treeNode.add(item);
}
return treeNode;
}I have also attached a screenshot of how this tree look like when rendered.

connysvensson
25 Jun 2008, 2:36 AM
I've also tested to call tree.expandAll(); in the end of the renderNavigation method but that doesn't do anything.

darrellmeyer
25 Jun 2008, 7:12 AM
You test code needs to be in this format (http://extjs.com/forum/showthread.php?t=33778).

connysvensson
25 Jun 2008, 10:43 PM
Instead of me posting a good code example you can just go to the AccordionLayout demo in the explorer to get the same behavior. I've included a screenshot so you can see how that looks. The correct behavior would be if the last folder would show it's children as well.
The screenshot below was taken from the online version from your site in FF3, but I get the same behavior locally in hosted mode (IE engine right?) with latest EXT-GWT 1.0rc1b.

gslender
26 Jun 2008, 12:25 AM
ok - so this is a bug. You might need to repost in the bugs forum as clearly this should work.

daliakamal
2 Sep 2009, 10:25 PM
Hello

I have the same problem , so i ask if anyone solve it or not
many thanks