0

我正在使用带有 enableCollapsibleOptGroups: true 的Bootstrap Multiselect,当单击 optgroup 标题复选框时,允许切换 optgroups 中的所有选项。在某些情况下,我需要预先选择选项,这可能意味着选择了 optgroup 中的所有选项。但是,在这种情况下,我不知道如何检查 optgroup 标头复选框。我可以选择 optgroup 中的所有选项,但不能选择 optgroup 标题复选框。这会强制用户单击它两次以取消选择该 optgoup 中的所有选项。我可以在隐藏字段中指出哪些 optgroup 已选择所有选项,但我无法弄清楚如何实际检查 optgroup 标题复选框。有什么建议么? 在此处输入图像描述

 $("select[id$='ddlLocation']").multiselect({
        enableCollapsibleOptGroups: true,
        includeSelectAllOption: true,
        maxHeight: 200,
        onDropdownHide: function (event) {
            $("select[id$='ddlLocation']").multiselect("updateButtonText");
            $("select[id$='ddlLocation']").multiselect("updateSelectAll");
            var arrLocations = [];
            var locations = $("#ddlLocation option:selected"); 
            $(locations).each(function(index, location){
                arrLocations.push([$(this).val()]);
            });
            if (arrLocations.length > 0) {
                $("input[id$='hdfLocationIds']").val(arrLocations);
                var prm = Sys.WebForms.PageRequestManager.getInstance();
                prm._doPostBack("btnParticipantLookup", 'getUserCnt');
            }
        }
    });
    var locationIds = $("input[id$='hdfLocationIds']").val();
    if (locationIds.length > 0)
    {
        $("select[id$='ddlLocation']").multiselect("select", locationIds.split(","));
    }
4

1 回答 1

0

这已经被集成/修复了。您可以在此处找到相应的示例(该enableClickableOptGroups选项的最后一个示例):http ://davidstutz.github.io/bootstrap-multiselect/#configuration-options-enableClickableOptGroups 。记得升级到最新的 master 分支。

于 2016-04-19T20:56:08.623 回答