Disable row selection for a few rows only in a p:dataTable

Since 4.0 version, Primefaces datatable comes with a disabledSelection property.

<p:dataTable var="foo" value="#{bean.foos}" selection="#{bean.selectedFoo}" disabledSelection="#{foo.bar == 1}">
    <p:column selectionMode="single" />
    <p:column>
        <h:outputText value="#{foo.bar}" />
    </p:column>
<p:dataTable>

Then, when foo.bar == 1 is true, checkbox will be disabled.

Leave a Comment