I have a Datatable with pagination and I want to change the current page with a commandlink outside the Datatable, how I can get it?
<p:commandLink title="changePage" action="#{myBean.changeMethod}"
update="myDataTable" />
<p:dataTable id="myDataTable" var="myItem" paginator="true" rows="1"
value="#{myBean.ListOfItem}" binding="#{myBean.DataTable}">
...
...
</p:dataTable>
Greetings!
This will set the page of the table to the first one
public void changeMethod() {
final DataTable d = (DataTable) FacesContext.getCurrentInstance().getViewRoot()
.findComponent("myDataTable");
int first = 0;
d.setFirst(first);
}
Or on client side:
widgetVar.getPaginator().setPage(pageindex);
EDIT : The "first" attribute indicates the index of the first row to be displayed