I want to change dataTable content with p:commandLink. To avoid being on a page number that is bigger then the actual page I always want to set the page to 1. I partially solved this with this code:
Code: Select all
<p:commandLink value="filter" action="#{controller.renewDataModel}" onclick="myDataTable.get('paginator').setPage(1,false);" update="dataTablePanel"/>
<h:panelGrid id="dataTablePanel">
<p:dataTable widgetVar="myDataTable" ... >
.....
</p:dataTable>
</h:panelGrid>
But when I'm on page 100 in my datatable, and I filter so I only have one page it sometimes says "No records found". When I filter back to the datasource with 100 pages, i'm back at page 100 for a millisecond. So I guess the onclick="myDataTable.get('paginator').setPage(1,false);" isn't allways executed.
Does someone know a solution?