开发者

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 r开发者_开发百科eally 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.


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!


I haven't tested it but PrimeFaces does support German locale. 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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜