Primefaces' Datatable pagination is not working fine with filtered values

别说谁变了你拦得住时间么 提交于 2019-12-11 09:25:24

问题


I am using JSF 2.0 with with PrimeFaces 5.2 in my Web Application. On a page there is a Datatable wich shows Tickets stored in Database in paginated form. Normally pagination is working fine but when I filter the Tickets using filterBy, it returns 4 pages, in which first page shows correctly filtered Ticktes, as soon as I click on page 2 or any page number greater than 1, the Datatable does not show filtered results rather it shows the unfiltered tickets of respective page as if no filter was applied, I want filtered results on other pages also .

More precisely I want that when I click on a page number greater than 1 , Datatable fetch respective page from the set of filtered tickets not form the set of all the Tickets. How can I do this?

I have gone through PrimeFaces 5.2' User-Guide , and read the attributes of the Datatable and tried a few which seemed helpful but problem still remains.

here is my Datatable,

<p:dataTable id="tickets" var="ticket"
                value="#{ticketBean.ticketModels}" paginator="true" rows="10"
                filteredValue="#{ticketBean.filteredTickets}">



                <p:column headerText="Summary" style="width:300px;">
                    <h:outputText value="#{ticket.summary}" />
                </p:column>



                <p:column headerText="Status" filterBy="#{ticket.status}"
                    filterOptions="#{ticketBean.statusFilterList}"
                    filterMatchMode="exact" style="width:110px;">
                    <h:outputText value="#{ticket.status}" />
                </p:column>

                <p:column headerText="Assigned To" filterBy="#{ticket.assignedTo}"
                    filterOptions="#{ticketBean.userFilterList}" filterMatchMode="exact"
                    style="width:110px;">
                    <h:outputText value="#{ticket.assignedTo}" />
                </p:column>
    ....................................
            </p:dataTable>

回答1:


Just add the below line to your p:datatable and check the same

paginator="true" rows="10" 
paginatorTemplate="{CurrentPageReport}  {FirstPageLink} 
{PreviousPageLink} {PageLinks}
{NextPageLink} {LastPageLink} {RowsPerPageDropdown} " 
rowsPerPageTemplate="10,15,20"


来源:https://stackoverflow.com/questions/29818744/primefaces-datatable-pagination-is-not-working-fine-with-filtered-values

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!