momalley
9 Jul 2009, 7:57 AM
If a tree is in a hidden container when expandAll() is called, many of the nodes are not correctly displayed. They are invisible. They still take up space and show the hover indicator, but nothing is displayed inside them.
The reason for this appears to be the code that checks whether the node is 'visible'. If a node is in a hidden element, this check won't consider it to be visible (most likely because anything in a hidden element has zero height). When a child node is 'not visible' it will be render only the main content without the body. Hence, invisible nodes.
Sample code to see this effect:
public class Sandbox implements EntryPoint {
public void onModuleLoad() {
// Create a simple tree and store
final TreeStore<ModelData> store = new TreeStore<ModelData>();
final TreePanel<ModelData> tree = new TreePanel<ModelData>(store);
tree.setDisplayProperty("name");
// Add nodes
Folder model = TestData.getTreeModel();
store.add(model.getChildren(), true);
// Add the tree to a hidden container
final LayoutContainer container = new LayoutContainer();
container.add(tree);
container.hide();
// Expand the tree
tree.expandAll();
RootPanel.get().add(container);
// Add a button to show the container
RootPanel.get().add(new Button("Add Tree", new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
container.show();
}
}));
}
}
One workaround I've found to work is to set tree like this:
tree = new TreePanel<ModelData>(store) {
@Override
protected int getVisibleRowCount() {
return nodes.size();
}
};
However, I do not know if this will cover all cases, and I'd prefer a better solution.
Are there any workarounds to this problem? Suppose you cannot wait for the hidden container to be displayed before calling expand. Would it be possible to have an option to turn off the visibility check?
Other info:
GXT version 2.0 final
Host mode and web mode
IE and Firefox
Windows XP
The reason for this appears to be the code that checks whether the node is 'visible'. If a node is in a hidden element, this check won't consider it to be visible (most likely because anything in a hidden element has zero height). When a child node is 'not visible' it will be render only the main content without the body. Hence, invisible nodes.
Sample code to see this effect:
public class Sandbox implements EntryPoint {
public void onModuleLoad() {
// Create a simple tree and store
final TreeStore<ModelData> store = new TreeStore<ModelData>();
final TreePanel<ModelData> tree = new TreePanel<ModelData>(store);
tree.setDisplayProperty("name");
// Add nodes
Folder model = TestData.getTreeModel();
store.add(model.getChildren(), true);
// Add the tree to a hidden container
final LayoutContainer container = new LayoutContainer();
container.add(tree);
container.hide();
// Expand the tree
tree.expandAll();
RootPanel.get().add(container);
// Add a button to show the container
RootPanel.get().add(new Button("Add Tree", new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
container.show();
}
}));
}
}
One workaround I've found to work is to set tree like this:
tree = new TreePanel<ModelData>(store) {
@Override
protected int getVisibleRowCount() {
return nodes.size();
}
};
However, I do not know if this will cover all cases, and I'd prefer a better solution.
Are there any workarounds to this problem? Suppose you cannot wait for the hidden container to be displayed before calling expand. Would it be possible to have an option to turn off the visibility check?
Other info:
GXT version 2.0 final
Host mode and web mode
IE and Firefox
Windows XP