combobox添加复选框

问题:

  需求提出要做一个下拉框可以多选的

 

解决方案:

//机构树
function initOrgTree() {
    $('#reportOrg').combobox({
        width: 200,
        editable: false,
        multiple: true,
        url: 'fileServiceType/getAllBanks',
        queryParams: {
            Authorization: localStorage.token
        },
        valueField: 'bank_id',
        textField: 'bank_name',
        formatter: function (row) {
            var opts = $(this).combobox('options');
            return '' + row[opts.textField]
        },
        onSelect: function (row) {
            var opts = $(this).combobox('options');
            var el = opts.finder.getEl(this, row[opts.valueField]);
            el.find('input.combobox-checkbox')._propAttr('checked', true);
        },
        onUnselect: function (row) {
            var opts = $(this).combobox('options');
            var el = opts.finder.getEl(this, row[opts.valueField]);
            el.find('input.combobox-checkbox')._propAttr('checked', false);
        },
        onLoadSuccess: function () {
            var opts = $(this).combobox('options');
            var target = this;
            var values = $(target).combobox('getValues');
            $.map(values, function (value) {
                var el = opts.finder.getEl(target, value);
                el.find('input.combobox-checkbox')._propAttr('checked', true);
            })
        }
    });
}

 

转载于:https://www.cnblogs.com/hackxiyu/p/8006493.html

你可能感兴趣的:(combobox添加复选框)