有没有办法从Qooxdoo中的数组初始化SelectBox中的项?
这看起来很基本,但似乎找不到实现的方法:我想从数组中初始化SelectBox有没有办法从Qooxdoo中的数组初始化SelectBox中的项?,qooxdoo,Qooxdoo,这看起来很基本,但似乎找不到实现的方法:我想从数组中初始化SelectBox var array = ["item1","item2"...] 而不必在列表项中循环 var selectBox = new qx.ui.form.SelectBox(); var test = ["item1", "item2"]; for (var i = 0; i < test.length; i++){ var tempItem = new qx.ui.form.ListItem(test[i
var array = ["item1","item2"...]
而不必在列表项中循环
var selectBox = new qx.ui.form.SelectBox();
var test = ["item1", "item2"];
for (var i = 0; i < test.length; i++){
var tempItem = new qx.ui.form.ListItem(test[i]);
selectBox.add(tempItem);
}
var-selectBox=newqx.ui.form.selectBox();
var测试=[“项目1”,“项目2”];
对于(变量i=0;i
在Qooxdoo中有什么方法可以做到这一点吗?首先,您的循环有一个更优雅的版本:
var selectBox = new qx.ui.form.SelectBox();
test = ["item1", "item2"];
test.forEach(function(obj) {
selectBox.add(new qx.ui.form.ListItem(obj));
}, this);
但是您应该看看Qooxdoo()中的数据绑定文档。使用此选项时,您可以得到如下解决方案:
var selectBox = new qx.ui.form.SelectBox();
test = ["item1", "item2"];
new qx.data.controller.List(new qx.data.Array(test), selectBox);
使用控制器时,您可以获得一些更有趣的功能,如轻松地将更改事件绑定到其他小部件等。首先是更优雅的循环版本:
var selectBox = new qx.ui.form.SelectBox();
test = ["item1", "item2"];
test.forEach(function(obj) {
selectBox.add(new qx.ui.form.ListItem(obj));
}, this);
但是您应该看看Qooxdoo()中的数据绑定文档。使用此选项时,您可以得到如下解决方案:
var selectBox = new qx.ui.form.SelectBox();
test = ["item1", "item2"];
new qx.data.controller.List(new qx.data.Array(test), selectBox);
当使用控制器时,您可以获得一些更有趣的功能,如轻松地将更改事件绑定到其他小部件等。谢谢,这正是我想要的!谢谢,这正是我要找的!