Re: [qooxdoo-devel] SelectBox and DataBinding (round 25)
Brought to you by:
ecker,
martinwittemann
From: Guilherme A. <gr...@gm...> - 2010-04-30 12:43:17
|
Right, Eduardo. That would solve my problem. If modelPath is not set then the whole object is what you want to get (just like you have today). Setting modelPath to "id" should then set the widget children model too: listItem.setModel(objectModel.getId()); So many questions about simple data binding problems should be considered warnings that something should be done. I mean, the whole data binding stuff is great, powerfull and well-thought. But it seems that an even higher abstraction layer is needed, at least default converters for those cases that you use everyday. On Fri, Apr 30, 2010 at 8:09 AM, Eduardo Robles Elvira <ed...@gm...>wrote: > On Fri, Apr 30, 2010 at 12:46 PM, MartinWittemann > <mar...@1u...> wrote: > > So no, that can't be achieved without a converter. And as I already said > in > > another thread about almost the same thing, I'm not sure if it's really > the > > right decision to strip down the model which we used to fill the form > > initially. I think thats a problem of serialization if you don't want to > > send all data to the server. > > > > Regards, > > Martin > > Hello: > > As I mentioned in the other thread, I think it would be nice idea to > have somthing like: > > qx.data.controller.List#setModelPath, in the same way you have > qx.data.controller.List#setLabelPath or > qx.data.controller.List#setIconPath. With that hypothetical solution, > the code in the first example provided by Guilherme would be written > as: > > > // create some dummy data > var data = { > firstname: "Martin", > lastname: "Wittemann", > gender: null > }; > var model = qx.data.marshal.Json.createModel(data); > > var listModel = qx.data.marshal.Json.createModel([ > {name: "male", id: 1}, > {name: "female", id: 2}, > {name: "dont know!", id: 3}, > {name: "Alien", id: 4} > ]); > > // create the form > var form = new qx.ui.form.Form(); > > // firstname > var firstname = new qx.ui.form.TextField(); > form.add(firstname, "Firstname"); > > // lastname > var lastname = new qx.ui.form.TextField(); > form.add(lastname, "Lastname"); > > // gender > var gender = new qx.ui.form.SelectBox(); > var controller = new qx.data.controller.List(listModel, gender, > "name"); > controller.setModelPath("id"); > form.add(gender, "Gender"); > > // create the form and add it to the root > this.getRoot().add(new qx.ui.form.renderer.Single(form), {left: > 30, top: 20}); > > // create a form controller > var oc = new qx.data.controller.Form(model, form); > > // A button to log the models content > var logButton = new qx.ui.form.Button("Show model data in the log"); > this.getRoot().add(logButton, {left: 240, top: 20}); > logButton.addListener("execute", function() { > this.debug(qx.dev.Debug.debugProperties(model)); > }, this); > > Regards, > Eduardo Robles Elvira. > > > ------------------------------------------------------------------------------ > _______________________________________________ > qooxdoo-devel mailing list > qoo...@li... > https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel > |