Hey,
hm, sounds like a hard challenge when the property itself changes. But i guess
you won't get it working by using the bindItem method. This is called if the
bindings need to be set up or renewed. It won't be called on a reorder of the
list for example which would break your example.
But I like challenges so i took the playground and came up wit a more or less
working solution. You won't get it working with a perfect synchronization but
if you don't need that, the solution is fine.
Just take a look at the example to see how it is done:
var data = qx.data.marshal.Json.createModel(
[
{data:"1"},
{data:"2",label:"** additional datas **"},
{data:"3"}
]);
var list = new qx.ui.form.List();
this.getRoot().add(list);
var converter = function(data) {
if (data.getLabel) {
return data.getLabel();
}
return data.getData();
}
var c = new qx.data.controller.List(null, list);
c.setLabelOptions({converter : converter});
c.setModel(data);
As you see, I'm using the converter which is called every time the binding
changes. That way, i can decide if there is a label property on the model. But
as i said, there is a catch! If you now change the label or data property (only
the properties itself) of one item of the list, the list wont get updated. That
because we are binding the model item itself to the label and decide on the
converter what to return.
I hope that helps,
Martin
Am 18.11.2010 um 20:50 schrieb benco:
>
> Hello,
>
> I've a little problem with the binding features - I guess Martin will be the
> best candidate to answer but anybody has the solution, it's of course
> welcome :)
>
> I've a model with partial datas like in this example (and bound to a
> combobox via the listController):
>
> [
> {data:""},
> {data:"",label:"** additional datas **"},
> {data:""},
> {data:""},
> ...
> ]
>
> The problem is that, in my delegate object I'd like to do this kind of
> operation but I don't know how to code it:
>
> listController.setDelegate({bindItem: function(controller, item, index)
> {
> /** if label exists in the model, use label, else use datas **/
> controller.bindProperty(..., "label", null, item, index);
>
> controller.bindProperty("datas", "model", null, item, index);
> }});
>
> Any idea ?
>
> Best,
>
> BenoƮt.
>
> --
> View this message in context:
> http://qooxdoo.678.n2.nabble.com/How-to-tryBindProperty-tp5753053p5753053.html
> Sent from the qooxdoo mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
> Spend less time writing and rewriting code and more time creating great
> experiences on the web. Be a part of the beta today
> http://p.sf.net/sfu/msIE9-sfdev2dev
> _______________________________________________
> qooxdoo-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
Spend less time writing and rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel