Try passing your arraycollection in as a argument to your find_roots
function.  The function will then get called whenever the paramter is
altered.

--- In [email protected], "alexandermaccaw"
<[EMAIL PROTECTED]> wrote:
>
> I'm trying to populate a tree from a flat (non hierachial in the
> normal sense) array collection. This is made up of lots of objects in
> the form of FolderVO's. Now folders have parents ('parent-id') and I
> want to reflect that in the tree. So I have this function:
> public function get children():ArrayCollection {
>  var c:ArrayCollection = new ArrayCollection(model.folders.source); 
>  c.filterFunction = function(item:Object):Boolean {
>       return (item.parent_id == id); 
>  };
>  c.refresh();
>  return c;
> }
> 
> And I also want to find roots:
> public static function find_roots():ArrayCollection {
>  var roots:ArrayCollection = new ArrayCollection(model.folders.source);
>  roots.filterFunction = function(item:Object):Boolean { 
>  return (item.parent_id == 0);
>  };
>  roots.refresh();
>  return roots;
> }
> 
> Now, both these functions work and return the right values and I can
> set the tree's data provider to FolderVO.find_roots().
> However, when model.folders is updated or any of the nodes in it,
> children or find_roots isn't called, even though model.folders is
> bindable. Is there something I'm missing? I've tried using Paul's
> observer tag:
> http://weblogs.macromedia.com/paulw/archives/2006/05/the_worlds_smal.cfm
> And it works to a certain extent. When model.folders is completely
> flushed (deleted and added) it's called (and all the folders in the
> tree collapse again!). However when a single folder in model.folders
> is edited/deleted, it's not.
> 
> Any ideas, keep in mind I'd rather not rebuild the tree every time
> something is CRUDed? I have a feeling that root_folders and children
> aren't binding to model.folders properly.
>


Reply via email to