MultiSelectCombobox issue in dojo

喜你入骨 提交于 2019-12-01 01:16:39

As for your second question, you have to extend dojox.form.CheckedMultiSelect class and override _updateSelection and startup methods:

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 label = "";
            array.forEach(this.options, function(option) {
                if(option.selected) {
                    label += (label.length ? ", " : "") + option.label;
                }
            });

            this.dropDownButton.set("label", label.length ? label : this.label);
        }
    }

});

Use MyCheckedMultiSelect instead of dojox.form.CheckedMultiSelect:

var checkedMultiSelect = new MyCheckedMultiSelect ({
    dropDown: true,
    multiple: true,
    label: "Select something...",
    store: dataStore
}, "placeholder");

checkedMultiSelect.startup();

Again, I added this to the jsFiddle: http://jsfiddle.net/phusick/894af/

In addition to @Craig's solution there is also a way to add only a look&feel of checkboxes via CSS. If you inspect generated HTML, you can see that each row is represented as a table row <tr> with several table cells <td>. The table row of the selected item gets CSS class .dojoxCheckedMultiSelectMenuItemChecked, so I suggest to change styling of the first cell which always has class .dijitMenuItemIconCell:

td.dijitMenuItemIconCell {
    width: 16px;
    background-position: center center;
    background-repeat: no-repeat;
    background-image: url('some-unchecked-image-here.png');
}

tr.dojoxCheckedMultiSelectMenuItemChecked td.dijitMenuItemIconCell {
    background-image: url('some-checked-image-here.png');
}

So you will get:

I added this to the jsFiddle I was helping you with before: http://jsfiddle.net/phusick/894af/

Craig Swing

The CheckedMultiSelect does not provide checkboxes when the dropDown is set to true. It simply allows the user to click to click multiple items to select.

To implement what you want, take a look at my answer here:

Custom dojo Dropdown widget by inheriting _HasDropdown and _AutoCompleterMixin

In MyCustomDropDown, you will need to build the list of checkboxes and items as a custom widget. I would recommend looking at dojox.form._CheckedMultiSelectMenu and dojox.form._CheckedMultiSelectMenuItem and mimic the functionality there and just give a different ui (with checkboxes).

dojox.form.CheckedMultiSelect should have been showing the checkboxes, this ticket fixes the problem. https://bugs.dojotoolkit.org/ticket/17103

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!