Primefaces的数据表分页不适用于过滤后的值 [英] Primefaces' Datatable pagination is not working fine with filtered values

查看:109
本文介绍了Primefaces的数据表分页不适用于过滤后的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Web应用程序中将JSF 2.0PrimeFaces 5.2一起使用.在页面上,有一个Datatable夹,以分页的形式显示了存储在Database中的票证. 通常,pagination可以正常工作,但是当我使用filterBy过滤故障单时,它返回4页,在我单击第2页或任何大于1的页码后,第一页将显示正确过滤的票证. c2>不显示过滤结果,而是显示各个页面的未过滤票证,就好像没有应用过滤器一样,我也希望在其他页面上过滤结果.

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 .

更确切地说,我希望当我单击大于1的页码时,Datatable从已过滤的票证集中获取各个页面,而不是从所有票证中获取.我该怎么办?

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?

我已经阅读了PrimeFaces 5.2'用户指南,阅读了Datatable的属性,并尝试了一些似乎有用的方法,但问题仍然存在.

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.

这是我的数据表,

<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>

推荐答案

只需将以下行添加到您的p:datatable中并进行检查

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"

这篇关于Primefaces的数据表分页不适用于过滤后的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆