I have implemented org.primefaces.model.SelectableDataModel
.
Now when rendering my <p:dataTable>
based on the SelectableDataModel
I add a column with checkboxes by using:
<p:column selectionMode="multiple" />
For some rows I do not want the checkbox to appear, based on some attribute of the row.
I cannot see a way to do this. Is it possible with out the box Prime Faces functionality ?
You can disable the checkbox:
<p:column selectionMode="multiple" style="width:18px"
disabledSelection="#{car.color =='Black'}"
styleClass="#{car.color =='Black' ? 'selectionDisabled':''}"/>
The check box is now disabled, however, visible. Hide disabled checkbox with CSS:
td.selectionDisabled .ui-chkbox{
display: none;
}
I would suggest to use:
<p:dataTable disabledSelection="#{car.color =='Black'}" ... >
For me it works fine with PF 5.1. No need to manipulate column styleClass.
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