Hi,
 I just started to use qooxdoo and had the same problem with SelectBox.I
hope I  solved the problem like this:
        var doc = this.getRoot();
        this._selectBox     =new qx.ui.form.SelectBox();
        var listController      =new qx.data.controller.List(null,
this._selectBox, 'name');
        doc.add(this._selectBox);
// list.json
->http://demo.qooxdoo.org/devel/demobrowser/demo/data/json/list.json
        var store               =new
qx.data.store.Json('http://a.url.to.json/list.json');
        store.bind("model.items", listController, "model");
        this._selectBox.addListener("changeSelection", function() {
                             alert('Item label ->
'+this._selectBox.getModelSelection().getItem(0).getName()+
                                   '       '+
                                   'Item value ->
'+this._selectBox.getModelSelection().getItem(0).getType()
                                   );
                            },this);
  Sorry for the late post.
 alex

Martin Wittemann wrote:
> 
> 
> Hello Christian, 
> You remember some posts ago i told you i think of the problem with the mix
> of the ui and data model and i come up with a solutions later. 
> I have thought about it and also fixed a bit in the list controller and
> finally have an alternative:
> 
> // create the ui data
> var uidata = {
> "article":
> {"icon":"icon\/16\/actions\/document-new.png","label":"Article"},
> "book": {"icon":"icon\/16\/actions\/document-new.png","label":"Book
> (Monograph)"},
> "chapter": {"icon":"icon\/16\/actions\/document-new.png","label":"Book
> Chapter"}}; 
> 
> // extract the models to an separate array
> var modelData = [];
> for (var m in uidata) {
>   modelData.push(m);
> }
> var model = qx.data.marshal.Json.createModel(modelData,true);
> 
> selectBox = new qx.ui.form.SelectBox(); 
> 
> var controller = new qx.data.controller.List(null, selectBox); 
> controller.setIconPath("");
> controller.setLabelOptions({converter: function(value) {
>   return uidata[value].label;
> }});
> controller.setIconOptions({converter: function(value) {
>   return uidata[value].icon;
> }});
> controller.setModel(model); 
> 
> this.getRoot().add(selectBox);
> 
> this.debug("Selected Model: " + selectBox.getModelSelection().getItem(0));
> 
> As you can see if you run this code in the playground (trunk) you get the
> value as modelSelection as expected and the selectbox will also be filled
> as
> expected.
> What do you think of such a solution?
> 
> Best,
> Martin
> 
> 

-- 
View this message in context: 
http://www.nabble.com/How-to-use-data-binding-for-a-SelectBox-%28which-is-intended-for-single-selection%29-tp25473916p26083320.html
Sent from the qooxdoo-devel mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to