ListItem in Selectbox preselected(选中)
ListItem in Selectbox preselected (selected)
在基于 Qooxdoo 的应用程序中,我遇到了以下问题。
在 for 循环中,我必须在 Selectbox 中添加一个 ListItem。
this._selection.add(new qx.ui.form.ListItem(fieldName, null, field));
this._selection is class type of: **qx.ui.form.SelectBox**
我想要预先选择在此选择框中添加的特定 ListItem。
在 HTML 中是:
<option value="audi" selected>Audi</option>
最好的,驯兽师
您可以使用 setSelection
方法来做到这一点。这是一个示例,源自 http://www.qooxdoo.org/current/demobrowser/#widget~SelectBox.html:
的 demobrowser SelectBox 演示
var selectBox = new qx.ui.form.SelectBox();
for (var i=0; i<30; i++)
{
var tempItem = new qx.ui.form.ListItem("Item " + (i+1));
selectBox.add(tempItem);
// select sixth item
if (i == 5)
{
selectBox.setSelection([tempItem]);
}
}
德雷尔
在基于 Qooxdoo 的应用程序中,我遇到了以下问题。 在 for 循环中,我必须在 Selectbox 中添加一个 ListItem。
this._selection.add(new qx.ui.form.ListItem(fieldName, null, field));
this._selection is class type of: **qx.ui.form.SelectBox**
我想要预先选择在此选择框中添加的特定 ListItem。 在 HTML 中是:
<option value="audi" selected>Audi</option>
最好的,驯兽师
您可以使用 setSelection
方法来做到这一点。这是一个示例,源自 http://www.qooxdoo.org/current/demobrowser/#widget~SelectBox.html:
var selectBox = new qx.ui.form.SelectBox();
for (var i=0; i<30; i++)
{
var tempItem = new qx.ui.form.ListItem("Item " + (i+1));
selectBox.add(tempItem);
// select sixth item
if (i == 5)
{
selectBox.setSelection([tempItem]);
}
}
德雷尔