【问题标题】:ListItem in Selectbox preselected (selected)Selectbox 中的 ListItem 预选(选中)
【发布时间】:2018-09-27 14:14:34
【问题描述】:

在基于 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>

最好的,驯服者

【问题讨论】:

    标签: javascript javascript-objects qooxdoo


    【解决方案1】:

    您可以使用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]);
      }
    }
    

    德雷尔

    【讨论】:

    • 亲爱的 Derell, 非常感谢。它似乎工作
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-31
    • 2017-11-27
    • 2014-10-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多