PDA

View Full Version : [FNR] [1.2.4] Expand event not fired if there is no children



mariusz.pala
19 Jun 2009, 7:01 AM
Hi,

I have an async tree and I wrote my own expandPath(...) method, since the original one doesn't work with async tree. The problem is that I have to select the last node at the end. Everything is be fine when the last node contains some subnodes, but the problem is that the Expand event is not fired when there is no children nodes:


public void expand() {
if (item.root) {
return;
}
updateJointStyle();
if (item.getItemCount() == 0) {
return;
}
onIconStyleChange("");
if (item.tree.getAnimate()) {
animExpand();
} else {
containerEl.setVisible(true);
afterExpand();
}
}But why? The node is expanded, it just doesn't contain any childs. Without that event I'm not able to verify if the last node is expanded or not. So wheter the process is finished or not (there is no other event to listen).

Can you change this code as below:


if (item.getItemCount() == 0) {
afterExpand();
return;
}
Thanks,
Mariusz

mariusz.pala
21 Jun 2009, 10:20 AM
Can you answer on this? Are you able to fix it ASAP? I really need it, since I can't find a workaround for this. Thanks.

sven
21 Jun 2009, 10:24 AM
We are looking into this for the next release.

mariusz.pala
21 Jun 2009, 10:37 PM
Is there any chance to fix it in 1.2 version? We don't want to migrate for a while. Thanks.

sven
22 Jun 2009, 2:39 AM
when i said next release i was talking about one of the comming 1.2 releases.

mariusz.pala
23 Jun 2009, 6:06 AM
Actually my solution doesn't work for async tree... Somehow TreeBinder stops the setExpand method from invocation if there is no children, but I have no idea how to fix it. I realy need that event even on empty nodes. Can you help? Can you provide some workaround or code to change? Thanks

mariusz.pala
23 Jun 2009, 11:14 PM
Finally I found a solution!
Two changes are required:

1. TreeItemUI.expand() method:


public void expand() {
if (item.root) {
return;
}
updateJointStyle();
if (item.getItemCount() == 0) {
afterExpand();
return;
}
onIconStyleChange("");
if (item.tree.getAnimate()) {
animExpand();
} else {
containerEl.setVisible(true);
afterExpand();
}
}2. TreeBinder.renderChildren(..)


protected void renderChildren(M parent, List<M> children) {
TreeItem p = (TreeItem) findItem(parent);
p.setData("loaded", true);
p.enable();

boolean leaf = p.isLeaf();
p.removeAll();
p.setLeaf(leaf);

if (p.isRendered()) {
p.getUI().onLoadingChange(false);
}

boolean f = p.getData("force") != null;
p.setData("force", null);

for (M child : children) {
TreeItem item = createItem(child);
p.add(item);
if (f) {
item.setData("force", true);
loadChildren(item, false);
}
}

if (!f && !p.isLeaf() && p.getData("expand") != null) {
p.setExpanded(true);
} else if (p.isLeaf()) {
p.setLeaf(true);
}

if (p.isRendered()) {
p.getUI().updateJointStyle();
}
}Can you commit this to SVN? It really solves the problem :) Thanks

sven
24 Jun 2009, 6:21 AM
Fixed in SVN.

mariusz.pala
24 Jun 2009, 6:29 AM
The commited fix contains a mistake:

In TreeBinder.renderChildren there is:

if (!f && !p.isLeaf() && p.hasChildren() && p.getData("expand") != null) {

But should be:

if (!f && !p.isLeaf() && p.getData("expand") != null) {

sven
24 Jun 2009, 6:36 AM
Corrected that too.

mariusz.pala
24 Jun 2009, 6:41 AM
Thank you!