3
votes

I have a Primefaces datatable in a web application. One column contains a boolean (represented as selectBooleanCheckbox). Now I'd like to filter the table with this column. When I add the filterBy and filterMatchMode attributes the filtering header appears, but I have to filter using true or false.

This is the definition of the column:

<p:column headerText="A Bool" sortBy="someBool" width="20"
    filterBy="someBool" filterMatchMode="exact">
   <h:selectBooleanCheckbox value="#{row.someBool}" disabled="true" />
</p:column>

The display of the column with a checkbox is correct. Only the header is displayed as a text field.

I'm using Primefaces 4. How can I get a check box in the header to filter the data?

1

1 Answers

0
votes

From Primefaces 4.0 User Guider, page 141:

If you’d like to use a dropdown instead of an input field to only allow predefined filter values use filterOptions attribute and a collection/array of selectitems as value

This way you could filter by selecting true or false on the list. But you want a checkbox on the header, you could try this (also from the user guide, page 142):

<f:facet name="header">
    <p:outputPanel>
        <h:outputText value="Search all fields:" />
        <h:inputText id="globalFilter" onkeyup="PF('carsTable').filter()" />
    </p:outputPanel>
</facet>

I hope this can help you go in the right direction.