Sorry for the late reply. But thanks for that - most helpful.

For the last part of my question:-

"If possible, how can I use this array of Country objects in the SelectBox,
only showing the CountryName yet when one item is selected I'd like to be
able to get access to the actual Country object itself, in order to get to
the 2 letter Country code?"

I've contrived a playground example - so how can I display the country name
in the SelectBox yet get a handle back on the entire country object for that
selected name?

Cheers!


/* ************************************************************************

#asset(qx/icon/${qx.icontheme}/16/devices/*)

************************************************************************ */

qx.Class.define("demobrowser.demo.widget.SelectBox",
{
  extend : qx.application.Standalone,

  members :
  {
    main: function()
    {
      this.base(arguments);

      var scroller = new qx.ui.container.Scroll();

      var box = new qx.ui.container.Composite(new qx.ui.layout.HBox(50));
      box.setPadding(20);

      box.add(this.createBox5());

      scroller.add(box, {left : 20, top : 20});
      this.getRoot().add(scroller, {edge : 0});
    },


    createBox5 : function()
    {
      var container = new qx.ui.container.Composite(new
qx.ui.layout.VBox(2));
      container.add(new qx.ui.basic.Label("Complex"));

      var myJSONObject = {"countries": [
        {"name": "United Kingdom", "code": "UK", "currency": "GBP"},
        {"name": "United States", "code": "US", "currency": "USD"},
        {"name": "Japan", "code": "JP", "currency": "JPY"}
      ]
      };
      this.debug("json " + myJSONObject.countries[0].name);
      
      var jsonmodel = new qx.data.Array(myJSONObject.bindings);

      var model = new qx.data.Array(["A", "B", "C", "D", "E", "F", "G", "H",
"I", "J"]);

      // first example, binding a selectbox and sync the selection
      var selectBox = new qx.ui.form.SelectBox();

      // connect the selectbox
      var controller1 = new qx.data.controller.List(model, selectBox);

      // How can I use the jsonmodel to show say the method in the
SelectBox?
      // eg I'd like to do :- var controller1 = new
qx.data.controller.List(jsonmodel, selectBox, "method");
      // And then in the changeSelection listener I'd like to be returned
the country element
      // so that I can access the "code" for the "name" selected (or
"currency" even!)?
      
      
      selectBox.addListener("changeSelection", function(e) {
        this.debug("complex changeSelection e.getData()[0]: " +
e.getData()[0]);
        this.debug("complex changeSelection e.getData()[0].getModel(): " +
e.getData()[0].getModel());
      });

      container.add(selectBox);

      return container;
    }

  }
});
 
-- 
View this message in context: 
http://qooxdoo.678.n2.nabble.com/SelectBox-demo-tp5519848p5543518.html
Sent from the qooxdoo mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to