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
a5261c141997MercedesWhite
9b9bf5ab1992BMWBlue
f1932f2b1992ChryslerBrown
460eef9d1980FerrariBlack
1538c9041996RenaultMaroon
a1fdf49f2008OpelRed
6c7f5df31980RenaultBrown
250c4fd31982RenaultSilver
1cd2ad4b2006BMWBlue

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>