JSF Primefaces data matching mode for global filter (not a separate column)

What is the filter matching mode for global filter(rather than a separate column filter, which defaults to "startsWith") and how to change it?

I ask that when I use a global filter with a matching mode set to "startsWith" in all my columns, I still get values ​​with a "contains" filter mode. See screenshot below.

country table screenshot

I should not get rows other than the first row, since I specified "startsWith" in all columns.

Here is my datatable,

<h:form id="countryTable">
<p:dataTable rowKey="" value="#{countryBean.countriesList}"
    var="country" selection="#{countryBean.selectedCountries}"
    styleClass="data-table-style" widgetVar="countryTableWVar"
    filteredValue="#{countryBean.filteredCountries}">
    <f:facet name="header">
        <div class="align-left">
            <p:outputPanel>
                <h:outputText value="Search all fields:" />
                <p:inputText id="globalFilter" onkeyup="countryTableWVar.filter();"
                    style="width:150px" />
            </p:outputPanel>
        </div>

    </f:facet>
    <p:column selectionMode="multiple" style="width:2%;" />
    <p:column headerText="Numeric Code" filterMatchMode="startsWith"
        filterStyle="display:none" filterBy="numericCode">
        <h:outputText value="#{country.numericCode}"></h:outputText>
    </p:column>
    <p:column headerText="Alpha_2 Code" filterMatchMode="startsWith"
        filterStyle="display:none" filterBy="alpha2">
        <h:outputText value="#{country.alpha2}"></h:outputText>
    </p:column>
    <p:column headerText="Alpha_3 Code" filterMatchMode="startsWith"
        filterStyle="display:none" filterBy="alpha3">
        <h:outputText value="#{country.alpha3}"></h:outputText>
    </p:column>
    <p:column headerText="Name" filterMatchMode="startsWith"
        filterStyle="display:none" filterBy="name">
        <h:outputText value="#{country.name}"></h:outputText>
    </p:column>
</p:dataTable>
</h:form>

How to change global global filter mapping mode?

+4
2

org.primefaces.component.datatable.feature.FilterFeature.java

133 , contains String

if(columnValue.toLowerCase(filterLocale).contains(globalFilter)){
    globalMatch = true;
}

, , .

+2

From Primefaces 4.0 docs:

, , , , , filter(), globalFilter datatable.

:

<p:dataTable var="car" value="#{carBean.cars}" 
filteredValue="#{carBean.filteredCars}" widgetVar="carsTable">
    <f:facet name="header">
        <p:outputPanel>
            <h:outputText value="Search all fields:" />
            <h:inputText id="globalFilter" onkeyup="PF('carsTable').filter()" />
        </p:outputPanel>
    </f:facet>
    <p:column filterBy="model" headerText="Model" filterMatchMode="contains">
        <h:outputText value="#{car.model}" />
    </p:column>
    <p:column filterBy="year" headerText="Year" footerText="startsWith">
        <h:outputText value="#{car.year}" />
    </p:column>
    <p:column filterBy="manufacturer" headerText="Manufacturer" 
filterOptions="#{carBean.manufacturerOptions}" filterMatchMode="exact">
        <h:outputText value="#{car.manufacturer}" />
    </p:column>
    <p:column filterBy="color" headerText="Color" filterMatchMode="endsWith">
        <h:outputText value="#{car.color}" />
    </p:column>
</p:dataTable>

startsWith endsWith . .

+1

All Articles