SelectCheckboxMenu - Disable All-Select

I have a SelectCheckBoxMenu (Primefaces component) with lots of entries. However, the user can select max. 3 subjects. SelectCheckBoxMenu fulfills almost all my requirements, the only problem is that it makes it possible to select all the elements that I obviously do not need in this case.

Is it possible to disable the "select all" option? I use event to check records for max. 3. I think I could do the same for select-all and not let him select them, but I don’t want to have the select-all option at all .

Below is the code:

<p:selectCheckboxMenu value="#{services.titelId}" id="titel" 
            panelStyle="width:160px;" rendered="#{!services.isFirma()}"
            label="#{services.prepareTitel()}" style="width:160px;"
            styleClass="checkbox">
            <f:selectItems value="#{meta.getAkadTitelList()}" />
            <p:ajax event="change" listener="#{services.validateTitel()}"
                update="titel" process="@this" />
            <p:ajax event="toggleSelect" update="titel" process="@this" />
</p:selectCheckboxMenu>

Also, a link to an example Primefaces showcase: https://www.primefaces.org/showcase/ui/input/checkboxMenu.xhtml

+6
source share
2 answers

You can add css rule to your css file

#titel .ui-chkbox .ui-widget {
     display:none;
}

You must add prependId="false"to yours h:form, or if you do not want to add prependId="false", you can change the selector #titel .ui-chkbox .ui-widgetto something like #myForm\3A titel .ui-chkbox .ui-widget(to handle the :Seperator identifier )


If you want to delete the entire filter line, you can set

<p:selectCheckboxMenu filter="false"....
+5
source

The previous answer did not work for me in PrimeFaces 5.0, so I delved into the generated HTML and found a solution for PF5.

For PrimeFaces 5.0, you can clear the Select All checkbox as follows:

.without-selectall .ui-selectcheckboxmenu-header .ui-chkbox {
    display: none; 
}

panelStyleClass - styleClass:

<p:selectCheckboxMenu ...
    panelStyleClass="without-selectall"
>
+14

All Articles