I have a SelectCheckBoxMenu (Primefaces component) with plenty of entries. However, the user is allowed to select max. 3 items. SelectCheckBoxMenu fullfils almost all my requirements, the only problem is that it offers the possibility to select all items, which i obviously don't need in this case.
Is there any possility to disable the "select-all" option? I am using an event to check the entries for max. 3. I think I could do the same for "select-all" and not allow him to select them, but I don't want to have the "select-all" option at all.
Below 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>
In addition, the link to the primefaces-showcase example: https://www.primefaces.org/showcase/ui/input/checkboxMenu.xhtml
The previous answer did not work for me under PrimeFaces 5.0, so I took a deeper look in the generated HTML and found a solution for PF5 as well.
For PrimeFaces 5.0 you can remove the "select all" checkbox like this:
.without-selectall .ui-selectcheckboxmenu-header .ui-chkbox {
display: none;
}
Now use panelStyleClass
-attribute instead of styleClass
:
<p:selectCheckboxMenu ...
panelStyleClass="without-selectall"
>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With