0
votes

I am facing some problems with filters in DataTable component in PrimeFaces !
I have a list of Employeesto show in that table and of course I have the ability to seach some of them using :

<f:facet name="header">
    <div align="left">
        <p:outputPanel>
            <p:inputText id="globalFilter" onkeyup="PF('employee_Table').filter()"  placeholder="#{msg['SearchFields']} " />
        </p:outputPanel>
    </div>
</f:facet>

enter image description here

The problem is after typing a text in that InputText and clearing it to start modifyin an other employee I still get the same employee that I searched for or a list of employees if the search criteria matches with more than one !

Is there a way to reset the filters ?

1
Would you happen to call the DB in the getter-method that returns the list? I'm not totally getting it, does the problem exist if you don't click the edit-button (pencil) you've highlighted? Or is the list correct, but you get the wrong employee when clicking the pencil? Do you have a rowkey on the table?Jaqen H'ghar
I get the wrong employee when I click on the pencil yeah ! The filter results are still in the memory. I found a solution and I'll put it as a response down ;) Thank you anywayGhassen Khalil ATI

1 Answers

1
votes

I found a solution to clear the filters when the page got called ! Sometimes one single code line takes of you one day unfortunately

Under the <p:form> element I got to add this line :

<p:remoteCommand name="onload" oncomplete="PF('employee_Table').clearFilters()" autoRun="true" />

Here employee_table is the value of widgetVar of my <p:datatable> element.