DataTable - Filtering

Datatable provides column based and global data filtering feature. There are four different match modes, "startsWith"(default), "endsWith", "contains" and "exact". In addition using filterOptions, predefined filter values can be displayed.

Search all fields:
ModelYearManufacturerColor
containsstartsWithexactendsWith
3c7e620b1965FerrariOrange
2f730e712007BMWRed
da4c6a191991BMWBlack
014b7f5b1960VolvoRed
7b4f87451975RenaultYellow
fc7a8f7b1960VolvoSilver
9881db041963MercedesBlue
2f7dae7a1993VolkswagenRed
ca29753d1988VolkswagenWhite

Source

<h:form>

    <p:dataTable id="dataTable" var="car" value="#{tableBean.carsSmall}" widgetVar="carsTable" 
            emptyMessage="No cars found with given criteria" filteredValue="#{tableBean.filteredCars}">

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

        <p:column id="modelColumn" filterBy="model" 
                headerText="Model" footerText="contains"
                filterMatchMode="contains">
            <h:outputText value="#{car.model}" />
        </p:column>

        <p:column id="yearColumn" filterBy="year"
                headerText="Year" footerText="startsWith">
            <h:outputText value="#{car.year}" />
        </p:column>

        <p:column id="manufacturerColumn" filterBy="manufacturer" 
                headerText="Manufacturer" footerText="exact"
                filterOptions="#{tableBean.manufacturerOptions}"
                filterMatchMode="exact">
            <h:outputText value="#{car.manufacturer}" />
        </p:column>

        <p:column id="colorColumn" filterBy="color"
                headerText="Color" footerText="endsWith" filterMatchMode="endsWith">
            <h:outputText value="#{car.color}" />
        </p:column>
    </p:dataTable>
    
</h:form>