Hey,

> I think this one is for Martin, as author of the Tree controller.
Exactly. :) 

> I'm using a Tree controller to populate a Tree. I need to attach a 
> context menu to some tree nodes, based on a property in the model of 
> that tree node.
> 
> I'm trying to do this by using a configureItem delegate:
> 
> {
>   configureItem : function(item) {
>     if (item.getModel().getSomeProperty()) {
>       item.setContextMenu(.......);
>     }
>   }
> }
> 
> This doesn't work, because the configureItem delegate gets called before 
> the model is attached to the tree node, so I can't access the model in 
> configureItem.

This should also not work. configureItem is called each time a new item is 
created or added to the tree. This does not have to be the same time the model 
gets updated. Imagine a dynamic change of that property the context menu 
depends on. configureItem will not be called because no item has been added at 
that point in time.

You should check out the bindItem method and use bindProperty to get that 
working. I would suggest to bind the "someProperty" which is responsible for 
the decision to show the menu to the contextMenu property itself. Sure, the 
property expects a menu but you can handle that in the converter. Just add a 
convert function to the options of the bindProperty method. In that converter, 
you get the data from the model property as parameter and can decide with that, 
which menu widget you would like to return. With that, you got it in line with 
the rest of the bindings and you have the dynamic behavior we all expect from 
the data binding for your custom binding as well.
Sounds like a good idea?

Regards,
Martin
------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to