E_lexy
E_lexy

Reputation: 141

qooxdoo mobile selectbox from json

I am trying to initialize / update a selectbox in Qooxdoo Mobile from json.

    this.__model = new qx.data.Array();
    var selQuestion = "substance released";
    sel = new qx.ui.mobile.form.SelectBox();
    sel.setDialogTitle(selQuestion);
    sel.setModel(this.__model);
    form.add(sel, selQuestion)

I have tried updating it using this method, but according to the manual the mobile lists are not supported yet.

test = ["item1", "item2"];
new qx.data.controller.List(new qx.data.Array(test), sel);

Also using the apply method on the property change I couldn't get it to work (the box stays empty):

__applySubstances : function(value, old) {
    this._model = new qx.data.Array();
    if(value) {
      for(i in value.toArray()) {
        this._model.push(value.toArray()[i].getName());
      }
    }
  }

Can anyone push me in the right direction?

Upvotes: 0

Views: 194

Answers (1)

czuendorf
czuendorf

Reputation: 863

I see no faults in your code. Could you please provide a playground example?

Please check the value parameter of your __applySubstances method.

Here is the example from the mobile showcase:

 var dd = new qx.data.Array(["Web search", "From a friend", "Offline ad"]);
      var selQuestion = "How did you hear about us ?";
      this.__sel = new qx.ui.mobile.form.SelectBox();
      this.__sel.set({required: true});
      this.__sel.set({placeholder:"Unknown"});
      this.__sel.setClearButtonLabel("Clear");
      this.__sel.setNullable(true);
      this.__sel.setDialogTitle(selQuestion);
      this.__sel.setModel(dd);
      this.__sel.setSelection(null);

      form.add(this.__sel, selQuestion);

Upvotes: 1

Related Questions