Hello Jean-Noël,
Jean-Noël Rivasseau wrote:
>
> 1) First is it possible to set a data binding from an array to another, so
> that the arrays always contain the same items (Eg, the data binding
> applies
> to the content of the arrays, not necessarily the property).
>
Ne, we don't have such a feature build in. Usually it's not that problem
using the same array for two views so we haven't seen a reason for that. But
implementing such a feature is not that much to do. Listen to the change
event of the source array and use the data send by the change event to
manipulate the target array. The data should contain every piece of
information you need.
Jean-Noël Rivasseau wrote:
>
> 2) This is my actual question. I want to setup a SelectBox whose items
> come
> from a bounded array (this I have already done a lot of times via the
> ListController). The trick here is that I would like to add an item on the
> selectbox, at the end of the menu, that is not on the source array. Eg,
> the
> menu should always contain all items from a source array plus a last one.
> Is
> there any easy support for that? (I've hacked something where I define an
> intermediate array and keeps adding the last item on this one, but it's
> not
> very clean).
>
We don't have support for that either. I didn't even think of such a use
case. ;)
The first thing that came to my mint is, that this is not a problem of the
data side, its a controller problem. So why don't just subclass the
controller, override _applyModel, call the base method and after that, add
you own listener to the changeLength of the model. If the length changes,
the listener for the list controller will be executed (it has been added
first) and after that, your handler will be executed. In that handler, you
can add your additional listItems to the target widget.
Here is some pseudo code of my idea:
qx.Class.define("myController", {
extend : qx.data.controller.List,
members : {
_applyModel : function(value, old) {
this.base(arguments, value, old);
if (old != null) {
old.removeListenerById(this.__id);
}
if (value != null) {
this.__id = value.addListener("changeLength", this.__update, this);
}
},
__update : function() {
var target = this.getTarget();
// add your listItems here...
}
}
});
But its also some kind of hack and I can't promise you that the whole
controller is working as expected (especially the selection). But it's worth
of giving a try I think. :)
Best,
Martin
--
View this message in context:
http://n2.nabble.com/Advanced-data-binding-on-arrays-tp4410233p4412397.html
Sent from the qooxdoo mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel