Primefaces p:datatable - 更改{CurrentPageReport}

Ioa*_* K. 4 javascript datatable jsf dynamic primefaces

我正在搜索和搜索,但我找不到任何解决我问题的方法.我使用DataTable(Primefaces)并想知道如何更改某些字段的语言/输出.

更准确地说,我想更改PaginatorTemplate中的{CurrentPageReport}.现在,它看起来很简单:(0 of 100).我想这样(第0页,共100页,500结果).

我尝试了很多,但没有任何作用.我做的最后一次是:

function change_text () {
    $(".ui-paginator-current").each (function() {
        $(this).html("Simple test");
    });     
}

$(".ui-icon").each(
            function(index) {
                $( this ).bind ("click",function(){ change_text (); });
            }
    );
Run Code Online (Sandbox Code Playgroud)

(ui-icon是表格中每个按钮的一部分.)

但这并不是真正有效的,因为你可以看到:-)这个解决方案是中途工作.当我按下按钮(下一页,上一页)时,.ui-paginator-current字段中的文本将更改回默认模板.我知道..原因是因为这个字段也在重新加载.

我也尝试更改Primefaces Code但我找不到正确的代码区域.

我正在使用JSF 2.0.3和PrimeFaces 2.2.1.我怎样才能解决我的问题?我可以从bean加载paginatorTemplate吗?如果我可以将文本从"0 of 100"更改为"0 aus 100"(德语),那将对我有所帮助.

希望你们能帮助我,就像我每次遇到问题一样.

Ioannis K.

Ioa*_* K. 21

找到了:

<p:dataTable currentPageReportTemplate="{currentPage} #{loc.of} {totalPages}" /> 
Run Code Online (Sandbox Code Playgroud)

对于那些感兴趣的人:-)

*现在:我喜欢这样:

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

currentPageReportTemplate="(Entries: {startRecord} - {endRecord} of {totalRecords}, Page: {currentPage}/{totalPages})"
Run Code Online (Sandbox Code Playgroud)

希望这可以帮助你们!

  • 您也可以这样做:`currentPageReportTemplate ="#{msg.PAGE_LABEL}"`其中`#{msg.PAGE_LABEL}`是存储在英语资源包中的{totalPages}`的"PAGE_LABEL = {currentPage}" MessageResources_en.properties).对于其他语言,只需翻译单词'**of**'并将每个翻译存储在其单独的资源包中,例如,对法语资源包执行此操作(MessageResources_fr.properties):`PAGE_LABEL = {currentPage} sur {totalPages }`.希望这可以帮助其他人在将来遇到这篇文章. (3认同)