简体   繁体   中英

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

addressTableBean.filteredAddressUnits 

in your bean, not even using new operator

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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