Hi Martin,
You're right of course!
I didn't think of using bindItem, but it's indeed the way to do this.
Took me a little time to realize that I also needed to call
bindDefaultProperties (turned out to be a case of RTFM ;) ), but it
works like a charm now:
{
bindItem : function(controller, item, id) {
controller.bindDefaultProperties(item, item.getModel());
controller.bindProperty("someProperty", "contextMenu", {
converter: function(value) {
return value ? someContextMenu : null;
}
}
}, item, id);
}
It's also much better since even the contextMenu can now change
dynamically based on the "some" property. The power of data binding is
amazing. :)
By the way. I noticed that the API doc of bindDefaultProperties() says
the first argument should be a TreeFolder. Shouldn't that be an
AbstractTreeItem instead?
Anyway, thanks for your help. :)
Regards,
Marc
On 05/09/2011 09:01 AM, Martin Wittemann wrote:
> 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