title: Bootstrap Multiselect - Check Optgroup Checkbox
body: <p>I'm using the <a href="http://davidstutz.github.io/bootstrap-multiselect/" rel="nofollow noreferrer">Bootstrap Multiselect</a> with enableCollapsibleOptGroups: true, allowing all options within optgroups to be toggled when the optgroup header checkbox is clicked.  In some instances I need to preselect the options, which can mean all options within an optgroup are selected.  However, I can't figure out how to check the optgroup header checkbox when this is the case.  I can get all the options within an optgroup selected, but not the optgroup header checkbox.  This forces the user to click it twice to deselect all options in that optgoup.  I could indicate in a hidden field which optgroups have all options selected, but I haven't been able to figure out how to actually check the optgroup header checkbox.  Any suggestions?
  <a href="https://i.stack.imgur.com/gmT4k.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gmT4k.png" alt="enter image description here"></a></p>
  
  <pre><code> $("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 &gt; 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 &gt; 0)
      {
          $("select[id$='ddlLocation']").multiselect("select", locationIds.split(","));
      }
  </code></pre>