Martin,

Thanks for the reply,   I understand what you are saying but I cannot change 
the data
{firstName: "dan", lastName: "green",

       ContactType:{__KEY:3}


Is there a way to specify what to bind to so that it will work with this data?

Thanks,
Dan
Date: Mon, 29 Jul 2013 00:39:44 -0700
From: [email protected]
To: [email protected]
Subject: Re: Selectbox form model binding and set selected value        to form 
model



        Hey,


Am 27.07.2013 um 07:24 schrieb dan <[hidden email]>:


> I have searched through the posts and docs but still not sure how to do this.

> 

> Basically can you automatically set the selected value of the selectbox

> based on id of the selectbox and the corresponding value in model of the

> form when you bind the form.  Textboxes get values automatically set by

> matching id to form model property, do I have to do this manually with

> selectboxes?

> 

> Scenario

> 

> Form with two text fields firtsName,lastName and a select box ContactType

> 

> remote json data via rest bound to the form

> json {firstName: "dan", lastName: "green",

>        ContactType:{__KEY:3}

>        }

> 

> Then I use a store to bind formController model

> var formController = new qx.data.controller.Form(null,form);

>  store.bind("model", formController , "model");

> 

> The selectbox has hardcoded data for testing but would in reality be pulled

> from remote json

> 

>   var rawData = [

>            {name: "Home", __KEY: 1},

>            {name: "Work", __KEY: 2},

>            {name: "Household", __KEY: 3},

> 

>        ]

> 

> //create selectbox model

>   var model = qx.data.marshal.Json.createModel(rawData);

> //create selectbox controller

>    var gender = new qx.ui.form.SelectBox();

>        var genderController = new qx.data.controller.List(null, gender);

>        genderController.setDelegate({bindItem: function(controller, item,

> index) {

>            controller.bindProperty("name", "label", null, item, index);

>            controller.bindProperty("__KEY", "model", null, item, index);

>        }});

>        genderController.setModel(model);

> 

>        form.add(gender, "ContactType")

> 

> The problem is when I load the from data via the formController

> firstName,lastName is filled in correctly but the SelectBox selected value

> is not automatically set to the value of ContactType for the forms model.

> 

> Do I have to manually set the value of all my selectboxes or is there

> automatic binding like in the form that uses the id of a textbox to find the

> corresponding record in the form model.

> 

> Also will the selectbox be two way so if I change the value it changes the

> value in the form model.

The binding should work the same as the textfield binding. Check out the sample 
here:

http://tinyurl.com/okuqopj

Most likely the problem's root is the data in your initial model. you set the 
contact type to {__KEY: 3} which is itself a model. But you tell the list 
controller that the model object of the list items is the value of your __KEY 
property which would be only the 3. So change the initial data from {__KEY: 3} 
to only 3 and it should work as expected.


Regards,

Martin

------------------------------------------------------------------------------

See everything from the browser to the database with AppDynamics

Get end-to-end visibility with application monitoring from AppDynamics

Isolate bottlenecks and diagnose root cause in seconds.

Start your free trial of AppDynamics Pro today!

http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________

qooxdoo-devel mailing list

[hidden email]

https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel


        
        
        
        

        

        
        
                If you reply to this email, your message will be added to the 
discussion below:
                
http://qooxdoo.678.n2.nabble.com/Selectbox-form-model-binding-and-set-selected-value-to-form-model-tp7584244p7584249.html
        
        
                
                To unsubscribe from Selectbox form model binding and set 
selected value to form model, click here.

                NAML
                                                  



--
View this message in context: 
http://qooxdoo.678.n2.nabble.com/RE-Selectbox-form-model-binding-and-set-selected-value-to-form-model-tp7584282.html
Sent from the qooxdoo mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Get your SQL database under version control now!
Version control is standard for application code, but databases havent 
caught up. So what steps can you take to put your SQL databases under 
version control? Why should you start doing it? Read more to find out.
http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to