Primefaces p:datatable - Change {CurrentPageReport}

19,053

Found it:

<p:dataTable currentPageReportTemplate="{currentPage} #{loc.of} {totalPages}" /> 

for those who are interested in it :-)

*Now: I have it like this:

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

currentPageReportTemplate="(Entries: {startRecord} - {endRecord} of {totalRecords}, Page: {currentPage}/{totalPages})"

Hope this helps you guys!

Share:
19,053
Ioannis K.
Author by

Ioannis K.

Updated on July 04, 2022

Comments

  • Ioannis K.
    Ioannis K. almost 2 years

    I`m searching and searching but I can not find anything to solve my problem. I use a DataTable (Primefaces) and wondered how I can change the language/output of some fields.

    More precisely, I want to change the {CurrentPageReport} in PaginatorTemplate. Now, it looks very simple: (0 of 100). I want to have it like this (Page 0 of 100, 500 results).

    I tried a lot, but nothing works. The last I did was:

    function change_text () {
        $(".ui-paginator-current").each (function() {
            $(this).html("Simple test");
        });     
    }
    
    $(".ui-icon").each(
                function(index) {
                    $( this ).bind ("click",function(){ change_text (); });
                }
        );
    

    (ui-icon is part of each button in the table.)

    But this is not really effective as you can see :-) This solution works half-way. When I press on a button (next page, previous page) the text in .ui-paginator-current field changes back to the default template. I know.. the reason is because this field is also being reloaded.

    I also tried to change Primefaces Code but I can`t find the correct code area.

    I am working with JSF 2.0.3 and PrimeFaces 2.2.1. How can I solve my problem? Can I load paginatorTemplate from a bean? It would really help me if I could change the text from "0 of 100" to "0 aus 100" (german).

    Hope you guys can help me, like every time I have a problem.

    Ioannis K.

  • Ioannis K.
    Ioannis K. about 13 years
    Yes I think I did. My (Our) project supports multilanguage and it checks on its own which default language in the browser of the user is set via faces-config.xhtml. FacesContext.getCurrentInstance().getViewRoot().setLocale() is being executed automatically and it works. When I change my browser language to german, my whole site is on german but not the page report.
  • Jörn Horstmann
    Jörn Horstmann about 13 years
    Ioannis K.: You might want to add that as an answer and accept that instead so the solution is easier to find for others.
  • Ioannis K.
    Ioannis K. about 13 years
    Youre right Jörn. I did it now.Ive just to learn how the things work here.
  • ChuongPham
    ChuongPham about 13 years
    You can also do this as well: currentPageReportTemplate="#{msg.PAGE_LABEL}" where #{msg.PAGE_LABEL} is PAGE_LABEL={currentPage} of {totalPages} that is stored in an English resource bundle (MessageResources_en.properties). For other languages, just translate the word 'of' and store each translation in its separate resource bundle, for example, do this for a French resource bundle (MessageResources_fr.properties): PAGE_LABEL={currentPage} sur {totalPages}. Hope this helps anyone else coming across this post in the future.
  • Mohammad Dehghan
    Mohammad Dehghan about 12 years
    @Ioannis: That actually helps a lot!