Java – Primefaces DataTable – Filtering [column not filtering]

datatablefilteringjavajsfprimefaces

I am trying this example 'DataTable – Filtering'. Everything works except for the Search all fields: textbox that filters. when i enter characters to it it doesn't filter as in the example.

There is no errors or exceptions thrown. I don't undestand what onkeyup="carsTable.filter()" does in the code. can someone explain this ? and any idea why it fails to filter

<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>

Best Solution

carsTable is the name of the datatable. Somehow its missing from the example, but the p:dataTable should have an attribute widgetVar="carsTable". onkeyup is the event that is firedafter you released a key. It tells the carsTable to filter after you entered a new character.

So add the widgetVar="carsTable" attribute to p:dataTable and you are good to go.

If you have a look at the PrimeFaces userguide, you will find the correct example.

Related Question