Cannot populate properly VirtualSelectBox

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Cannot populate properly VirtualSelectBox

voger
I am trying to subclass the qx.ui.form.VirtualSelectBox and create a
widget that on display communicates with the server and gets a list of
available gender choices.

If I subclass from qx.ui.form.VirtualComboBox  or if I try to run it in
playground it works as expected. Here is a link http://tinyurl.com/o4r9lsg

 From virtual select box I get this error:

006111 Assertion error! Invalid incoming value for property 'label' of
class 'qx.ui.basic.Atom': Expected value to be a string but found
qx.data.model.label"value[1369-0]!

The JSON.stringify(result) looks like this:

[{"label":"","value":"0"},{"label":"Male","value":"m"},{"label":"Female","value":"f"}]

Here is my code:

qx.Class.define("qssite.ui.form.widget.VirtualGenderSelect", {
     extend: qx.ui.form.VirtualSelectBox,

     construct: function(model) {
         this.base(arguments, model);
         this.addListenerOnce("appear", function() {
             this._onAppear();
         });
     },

     members: {
         _onAppear: function() {
             var rpc = new qx.io.remote.Rpc('/remote', 'qssite');
             var self = this;

             // asynchronous call
             var handler = function(result, exc) {
                 if (exc === null) {
                     console.log(JSON.stringify(result));
                     var model = qx.data.marshal.Json.createModel(result);
                     self.setModel(model);
                     self.setLabelPath('label');
                 } else {
                     this.debug("Exception during async call: " + exc);
                 }
             };

             rpc.callAsync(handler, 'qssite.get_gender_choices');
         }
     }
});

What I am doing wrong?

------------------------------------------------------------------------------
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Cannot populate properly VirtualSelectBox

voger
I noticed that when I reverse the order and first set the LabelPath and
then the model

                     self.setLabelPath('label');
                     self.setModel(model);

Then the VirtualComboBox gets populated. But still I have the same error
message,

On 24/07/2015 09:22 μμ, voger wrote:

> I am trying to subclass the qx.ui.form.VirtualSelectBox and create a
> widget that on display communicates with the server and gets a list of
> available gender choices.
>
> If I subclass from qx.ui.form.VirtualComboBox  or if I try to run it in
> playground it works as expected. Here is a link http://tinyurl.com/o4r9lsg
>
>   From virtual select box I get this error:
>
> 006111 Assertion error! Invalid incoming value for property 'label' of
> class 'qx.ui.basic.Atom': Expected value to be a string but found
> qx.data.model.label"value[1369-0]!
>
> The JSON.stringify(result) looks like this:
>
> [{"label":"","value":"0"},{"label":"Male","value":"m"},{"label":"Female","value":"f"}]
>
> Here is my code:
>
> qx.Class.define("qssite.ui.form.widget.VirtualGenderSelect", {
>       extend: qx.ui.form.VirtualSelectBox,
>
>       construct: function(model) {
>           this.base(arguments, model);
>           this.addListenerOnce("appear", function() {
>               this._onAppear();
>           });
>       },
>
>       members: {
>           _onAppear: function() {
>               var rpc = new qx.io.remote.Rpc('/remote', 'qssite');
>               var self = this;
>
>               // asynchronous call
>               var handler = function(result, exc) {
>                   if (exc === null) {
>                       console.log(JSON.stringify(result));
>                       var model = qx.data.marshal.Json.createModel(result);
>                       self.setModel(model);
>                       self.setLabelPath('label');
>                   } else {
>                       this.debug("Exception during async call: " + exc);
>                   }
>               };
>
>               rpc.callAsync(handler, 'qssite.get_gender_choices');
>           }
>       }
> });
>
> What I am doing wrong?
>
> ------------------------------------------------------------------------------
> _______________________________________________
> qooxdoo-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>


------------------------------------------------------------------------------
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel