1
votes

I have a flex tree component that has its data bind to a ArrayCollection. I also implemented a custom ITreeDataDescriptor to filter the tree. Everything works fine except the first level nodes will not disappear (be filtered) if there is no child node under it. It does work from the second level down.

any suggestion how it can be done? Only want to filter out the first level node when all its children node are been filtered out.

pretty much like this example, except Parent would disappear when children are gone

the source is an ArrayCollection and it's pretty much like the following

var dataSource:ArrayCollection = new ArrayCollection();
dataSource.addItem(myObject1);
dataSource.addItem(myObject2);
dataSource.addItem(myObject3);
dataSource.addItem(myObject4);

and in myObject1 ~ myObject4 there are children ArrayCollection with the same type.

1

1 Answers

0
votes

This is hard to answer without any code, but here are some suggestions on a approach:

  • make sure you have a root node so that you can also filter out the nodes at level 1 (the children of the root node)
  • do a recursive check in the getChildren() method of the ITreeDataDescriptor implementation to see if all children of a node are removed/hidden