Dijit 选择,组合框中的项目已禁用 = true 不起作用

Dijit Selects, Items in the Combobox disabled = true doesn't works

这是我的代码,它不起作用。它属于一个组合框。其中有些项目应该被禁用。

var data = [];

for (i = 0; i < items.length; i++) {
     data.push({id: items[i].id, label: "foobaa"});
     data.getOptions(items[i].id).disabled = true;
}

var memory = new Memory({
    idProperty: "id",
    data: data
});

this._widget.set("store", memory);

我在 fiddle.net 找到了一个代码 snipe,它可以工作,但我无法将它转换为我的问题。

http://jsfiddle.net/g00glen00b/akcZy/

此外,dojo 的超级文档对我没有帮助:-(

http://dojotoolkit.org/documentation/tutorials/1.10/selects_using_stores/

我做了一些更改试试这个,让我知道这是你的需要吗?使用下面的代码禁用所有 select 项。

 var data = [];

for (i = 0; i < myData.length; i++) {
  data.push('{id: myData[i].id, label: "foobaa"}');
  registry.byId("mySelect").getOptions(myData[i].id).disabled = true;
}

http://jsfiddle.net/f3snxrrd/

http://jsfiddle.net/5pgkkf0z/

items: {
        mutators: {
            value: [],
            type: verify.ARRAY
        },
        widget: {
            updateI18n: true,
            mapping: function (widget, items) {

                if (this._widget) {
                    var i;
                    var data = [];


                    for (i = 0; i < items.length; i++) {
                        data.push({id: items[i].id, label: i18n.resolveSequence(items[i].label)});
                        //register.byId(data).getOptions((items[i].value).disabled = true);
                    }


                    var memory = new Memory({
                        idProperty: "id",
                        data: data
                    });

                    this._widget.set("store", memory);

                    this._widget.closeDropDown(true);
                    this._widget.reset();

                    if (items.length === 0) {
                        this._enabledItems = false;
                    }
                    else if (items.length === 1) {
                        this.set("selectedId", items[0].id);
                        this._enabledItems = (this.get("selectedId") !==    items[0].id);
                    }
                    else {
                        this._enabledItems = true;
                    }

                   this._widget.set("disabled", !(this._enabledState && this._enabledItems ));
                }
            }
        }
    },




_createWidget: function () {
        var ret;
        ret = new Select({id: this.uniqueId, disabled: true, labelAttr: "label", labelType: "Text", required: false, store: new Memory({data: []})});


        var that = this;
        ret.own(on(ret, "change", function (value) {that._onChange(value); }));

        return ret;
    },

这是项目数组:

代码来自jsfiddle.net

http://jsfiddle.net/8m52n81u/11/

我无法更改项目数组:-/

items = [{
  id: "0",
  label: key[{0: "foo", 1: "baa"}]
}, {
  id: "1",
  label: key[{0: "foo", 1: "baa"}]
}];

require([
 "dojo/ready",
 "dijit/registry",
 "dijit/form/Select",
 "dojo/store/Memory",
 "dojo/parser"
], function(ready, registry) {
 ready(function() {

   var data = [];

   for (i = 0; i < items.length; i++) {
     data.push('{id: items[i].id, label: items[i].label}');
     registry.byId("uniqueId").getOptions(items[i].id).disabled = true;
   }

  });
});