P prime: datatable - Change {CurrentPageReport}

I am searching and searching, but I cannot find anything to solve my problem. I am using DataTable (Primefaces) and wondering how I can change the language / output of some fields.

More precisely, I want to change {CurrentPageReport} to a PaginatorTemplate. Now it looks very simple: (0 out of 100). I want this to be so (Page 0 of 100, 500 results).

I tried a lot, but nothing works. The last thing 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 (); }); } ); 

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

But this is not as effective as you can see :-) This solution works halfway. When I click the button (next page, previous page), the text in the .ui-paginator-current field returns to the default template. I know .. the reason is that this field is also reloading.

I also tried changing the Rules Code, but I cannot find the correct area of ​​the code.

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

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

Ioannis K.

+4
source share
2 answers

Found:

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

+19
source

I have not tested it, but PrimeFaces supports German. Have you tried setting the locale in your bean to see if "0 of 100" changes to "0 aus 100"?

 FacesContext.getCurrentInstance().getViewRoot().setLocale(new Locale("de")); 
0
source

Source: https://habr.com/ru/post/1345485/


All Articles