title: Primefaces Complex Datatable Filtering and Sorting
body: <p>I am using a complex datatable that can sort and filter with various filter. my problem is as I try to use column filter, global filter or sorting datatable pagination suddenly drops to 1 page and it doesn't turn back to first state with pagination. At the beginning I have 92 pages but after filtering/sorting it becomes a datatable with 1 page, even though I clear the textbox of filter it stays as 1 page.</p>
  
  <p>Here is my datatable:</p>
  
  <pre><code>&lt;h:panelGroup rendered="#{projectsController.items.rowCount &gt; 0}"&gt;
  &lt;p:growl id="growl" /&gt;  
  &lt;p:dataTable id="datatable" value="#{projectsController.items}" var="item" filterEvent="keyup" 
               paginator="true" rows="5" emptyMessage="Proje bulunamadı." paginatorPosition="bottom"  
               paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" 
               rowsPerPageTemplate="4,5,6,7,8,9,10" 
               filteredValue="#{projectsController.filteredProjects}" style="font-size:11px;font-weight: bold;"  widgetVar="proj" &gt;
  
      &lt;f:facet name="header"&gt;  
         &lt;p:outputPanel&gt;  
            &lt;h:outputText value="Tüm Alanlarda Ara:  " /&gt;  
            &lt;p:inputText id="globalFilter" onkeyup="proj.filter();" style="width:150px" /&gt;  
         &lt;/p:outputPanel&gt;  
      &lt;/f:facet&gt; 
  
  
      &lt;p:column id="c1" headerText="Proje Adı" width="500" filterStyle="display:none" styleClass="wrap" sortBy="#{item.projectname}" filterBy="#{item.projectname}" filterMatchMode="contains" &gt;
         &lt;h:outputText value="#{item.projectname}"/&gt;
      &lt;/p:column&gt;
  
      &lt;p:column headerText="İlçe" width="150" styleClass="wrap" filterStyle="display:none" filterBy="#{item.district}" sortBy="#{item.district}" filterOptions="#{populator.districtsDD}" filterMatchMode="exact"&gt;
          &lt;h:outputText value="#{item.district}"/&gt;
      &lt;/p:column&gt;
  
      &lt;p:column headerText="Sektör" width="150" styleClass="wrap" filterStyle="display:none" filterBy="#{item.sector}" sortBy="#{item.sector}" filterOptions="#{populator.sectorsDD}" filterMatchMode="exact"&gt;
          &lt;h:outputText value="#{item.sector}"/&gt;
      &lt;/p:column&gt;
  
      &lt;p:column headerText="Başlangıç Tarihi" width="150" styleClass="wrap" filterStyle="display:none" sortBy="#{item.startdate}" filterBy="#{item.startdate}" filterMatchMode="contains"&gt;
          &lt;h:outputText value="#{item.startdate}"/&gt;
      &lt;/p:column&gt;
  
      &lt;p:column headerText="Bitiş Tarihi" width="150" styleClass="wrap" filterStyle="display:none" sortBy="#{item.enddate}" filterBy="#{item.enddate}" filterMatchMode="contains"&gt;
          &lt;h:outputText value="#{item.enddate}"/&gt;
      &lt;/p:column&gt;
  
      &lt;p:column headerText="İş Durumu" width="150" styleClass="wrap" filterStyle="display:none" sortBy="#{item.workstatus}" filterBy="#{item.workstatus}" filterMatchMode="contains"&gt;
          &lt;h:outputText value="#{item.workstatus}"/&gt;
      &lt;/p:column&gt;
  
      &lt;p:column&gt;
          &lt;p:commandButton id="selectButton" update=":display" oncomplete="carDialog.show()" icon="ui-icon-search" title="Detayları Gör"&gt;  
             &lt;f:setPropertyActionListener value="#{item}" target="#{projectsController.selectedP}" /&gt;
             &lt;p:ajax event="click" update=":viewTabs:tabView:mapTab"/&gt;
          &lt;/p:commandButton&gt;
          &lt;p:commandButton id="editButton" update=":displayEdit" oncomplete="editDialog.show()" icon="ui-icon-pencil" title="Düzenle"&gt;  
             &lt;f:setPropertyActionListener value="#{item}" target="#{projectsController.selectedP}" /&gt;
           &lt;/p:commandButton&gt;
           &lt;p:commandButton update="growl" title="Projeyi Sil" id="confirm" action="#{projectsController.destroy}" icon="ui-icon-trash" ajax="false" onclick="if (!confirm('Bu projeyi gerçekten silmek istiyor musunuz?'))
                                              return false;"/&gt;  
        &lt;/p:column&gt;
  &lt;/p:dataTable&gt;
  </code></pre>
  
  <p>After filtering or sorting how can I reset my datatable to first state? Thanks in advance.</p>
  
  <p><em>Primefaces 3.5, Oracle WebLogic 10g, JSF 2.2</em></p>
  
  <p>Here is the snapshot:</p>
  
  <p>![enter image description here][1]</p>