0

我在页面上使用了 dojo checkedmuliselect 并让它正常工作。我如何配置它,以便无论我在哪里单击控件,下拉菜单都会打开?目前它仅在我单击控件的箭头部分时打开。这可能吗?

我从http://jsfiddle.net/phusick/894af/得到这个例子

当前代码:

require(["dojo/parser", "dijit/form/Form"]);

require([
    "dojo/_base/declare",
    "dojo/_base/lang",
    "dojo/_base/array",
    "dojo/on",
    "dojo/dom",
    "dojo/store/Memory",
    "dojo/store/Observable",
    "dojo/data/ObjectStore",
    "dojox/form/CheckedMultiSelect",
    "dijit/Tooltip",
    "dojo/mouse",
    "dojo/dom-attr",
    "dojo/query",
    "dojo/dom-class",
    "dijit/place",
    "dojo/domReady!"
], function( 
    declare,
    lang,
    array,
    on,
    dom,        
    Memory,
    Observable, 
    DataStore,
    CheckedMultiSelect,
    Tooltip,
    mouse,
    domAttr,
    query,
    domClass,
    place
) {

    var memoryStore = new Memory({
        idProperty: "value",
        data: [
            {value: "CT", label: "Label One"}
        ]
    });

    var dataStore = new DataStore({ 
        objectStore: memoryStore,
        labelProperty: "label" 
    });

    var MyCheckedMultiSelect = declare(CheckedMultiSelect, {

        startup: function() {
            this.inherited(arguments);  
            setTimeout(lang.hitch(this, function() {
                this.dropDownButton.set("label", this.label);            
            }));       

        },

        _updateSelection: function() {
            this.inherited(arguments);                
            if(this.dropDown && this.dropDownButton) {
                var numOptionsSelected = 0;
                var label = "";
                array.forEach(this.options, function(option) {
                    if (option.selected) {
                        label += (label.length ? ", " : "") + option.label;                     
                        numOptionsSelected++;
                    }
                });

                if (numOptionsSelected > 0) {
                  this.dropDownButton.set("label", label.length ? label : this.label);
                }

            }
        }       

    });

    var checkedMultiSelect = new MyCheckedMultiSelect ({
        dropDown: true,
        multiple: true,
        label: 'Code Table',
        name: 'queryType',
        store: dataStore
    }, "placeholder");

    array.forEach(checkedMultiSelect.options, function(option){ 
        option.selected = true;     
    });

    checkedMultiSelect.startup();

});
4

1 回答 1

1

我通过在checkedMultiSelect.startup() 之后使用以下代码更新jsfiddle 示例来管理它:

checkedMultiSelect.on('click', function(evt){
    if(evt.target.nodeName == "INPUT"){
        checkedMultiSelect.dropDownButton.toggleDropDown();
    }
});
于 2013-10-15T08:32:02.773 回答