Option to hide empty optgroups

Issue #4 resolved
Anonymous created an issue

Add option setting to hide headers for empty optgroups

Comments (7)

  1. lhaemmerle

    Find below a patch for updateListFilter(textControl) that hides empty categories/optgroups:

    //show nomatches item, and no other headers if the filter excludes everything
    var anyMatches = Boolean(listItems.filter(':visible').length!=0);        
    // Hide visible but empty categories
    var previousElement = null;
    var allListItems = listControl.children().filter(':visible');
    	function () {
    		if ($(this).hasClass("idd_listItemGroupHeader")){
    			if (previousElement != null && previousElement.hasClass("idd_listItemGroupHeader")){
    				//alert("Hide " + previousElement.text())
    		previousElement = $(this);
    // Hide last visible item if it is a category
    if (allListItems.last().hasClass("idd_listItemGroupHeader")){
    positionList(listControl); //resize list to fit new visible elements.

    What is missing is a switch to make this an option.

  2. lhaemmerle

    That last condition actually should be:

    if (allListItems.last().hasClass("idd_listItemGroupHeader") && !allListItems.last().hasClass("grpHdrNoMatches")){

    which ensures that the "No match found" entry is not hidden as well.

  3. Log in to comment