Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Primefaces p:datatable - Change {CurrentPageReport}

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.

like image 266
Ioannis K. Avatar asked Nov 28 '22 18:11

Ioannis K.


1 Answers

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!

like image 191
Ioannis K. Avatar answered Dec 01 '22 07:12

Ioannis K.