Search code examples
primefacesjsf-2pagination

Display an "Show All"-Option in DataTable-Paginator-Dropdown in PrimeFaces


I have Programm in Java, I Use Primefaces Pagination and lazy loading. I want to add "Show All" In rowsPerPageTemplate.

<p:dataTable var="info"
                    value="#{infoMB.lazyModel}"
                    id="infoTable"
                    width="100%"
                    liveResize="true"
                    paginator="true"
                    rows="50"
                    paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
                    rowsPerPageTemplate="50,100,"Show all" rowsPerPageAllEntry="true"
                    lazy="true">

Solution

  • To make a commandButton appear in your dataTable fallow this example :

    <p:dataTable ... >
    
       <f:facet name="header" > <p:commandButton value="Validate button" action="#{managedBean.method()}" > </p:commandButton> </f:facet>
    
     </p:dataTable ... >
    

    You can even show it in the bottom of your dataTable like this

     <p:dataTable ... >
    
       <f:facet name="footer" > <p:commandButton value="Validate button" action="#{managedBean.method()}" > </p:commandButton> </f:facet>
    
     </p:dataTable ... >
    

    Hope that helped you.