Hello Stefan,
thats an interesting task for the binding infrastructure. At the first
moment I thought it's an easy one but you are using comboboxes which makes
it not that easy as I thought in the first place. If it were select boxes,
it would be easy because they have a selection, which combo boxes don't.
But I took some time to get the thing working and here is an example:
var data = [
{name: "A", subtypes: [
{name: "a1"},
{name: "a2"}
]},
{name: "B", subtypes: [
{name: "b1"},
{name: "b2"}
]}
];
var model = qx.data.marshal.Json.createModel(data);
var type = new qx.ui.form.ComboBox();
this.getRoot().add(type);
var subtype = new qx.ui.form.ComboBox();
this.getRoot().add(subtype, {top: 30});
var typeController = new qx.data.controller.List(model, type, "name");
var subtypeContorller = new qx.data.controller.List(null, subtype, "name");
type.bind("value", subtypeContorller, "model", {converter : function(data) {
for (var i = 0; i < model.getLength(); i++) {
if (model.getItem(i).getName() == data) {
return model.getItem(i).getSubtypes();
}
}
return null;
}});
The trick is to bind the value of the first select box to the model of the
second select box controller and search for the fitting model in the
converter.
Unfortunately, I found a bug in the list selection handling for the
controllers which I added to the qooxdoo bugzilla. [1] So testing this code
throws an error but it works. I'm already working to fix the problem in the
framework so it should not take that long until that bug is fixed.
Regards,
Martin
[1] http://bugzilla.qooxdoo.org/show_bug.cgi?id=3544
--
View this message in context:
http://n2.nabble.com/A-bind-problem-tp4792757p4796199.html
Sent from the qooxdoo mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel