简体   繁体   English

过滤数据表后,分页不再显示在主字体中

[英]After filtering datatable, pagination is not rendered anymore in primefaces

I have created a datatable by using primefaces. 我已经使用素数创建了一个数据表。 It contains options filtering, sorting and pagination. 它包含过滤,排序和分页选项。 Before filtering table, pagination works correctly. 在过滤表之前,分页可以正常工作。 But when some data is filtered, pagination doesn't work. 但是,当某些数据被过滤时,分页将不起作用。 That means page numbers are not rendered. 这意味着不显示页码。 Before I have created datatable in my another application in the same way. 以同样的方式在另一个应用程序中创建数据表之前。 It works correctly. 它可以正常工作。 I tried LazyDataModel of primefaces in my code also. 我也在代码中尝试了Primefaces的LazyDataModel。 but it also didn't work. 但它也不起作用。 I can't figure out what is the error in my code. 我无法弄清楚代码中的错误是什么。

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
            xmlns:ui="http://java.sun.com/jsf/facelets"
            xmlns:h="http://java.sun.com/jsf/html"
            xmlns:p="http://primefaces.org/ui"
            xmlns:f="http://java.sun.com/jsf/core"
            template="home.xhtml">
<ui:define name="content">
    <p:tabView style="font-size: 12px" id="numberAnalyzerTab">
        <p:tab title="Number Analyzer">
            <h:form id="form">
                <p:messages id="msgs" showDetail="true" autoUpdate="true" closable="true"/>
                <p:dataTable id="dataTable"
                             var="addressEvent"
                             value="#{addressTableBean.addressUnits}"
                             rowKey="#{addressEvent.id}"
                             rows="10"
                             selectionMode="single"
                             paginator="true" filteredValue="#{addressTableBean.filteredAddressUnits}"
                             editable="true">

                    <f:facet name="header">
                        <h:outputText value="List of Addresses"/>
                    </f:facet>

                    <p:column headerText="Prefix" sortBy="#{addressEvent.numberPrefix}" filterBy="#{addressEvent.numberPrefix}" id="prifix">
                         #{addressEvent.numberPrefix}
                    </p:column>

                </p:dataTable>
            </h:form>
        </p:tab>
    </p:tabView>
</ui:define>

Try adding paginatorTemplate to p:datatable and make sure not to modify 尝试将paginatorTemplate添加到p:datatable,并确保不要进行修改

addressTableBean.filteredAddressUnits 

in your bean, not even using new operator 在您的bean中,甚至不使用new运算符

paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"

rowsPerPageTemplate="20,50,100" //Your values here

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM