我正在努力实现以下目标:-
以下是我的数据表代码:-
<p:dataTable id="datatableid"
var="record"
value="#{myController.records}"
selectionMode="single"
selection="#{myController.selectedRecord}"
rows="10"
paginator="true"
currentPageReportTemplate="{startRecord} - {endRecord} of {totalRecords} Records Displayed, {totalPages}"
paginatorTemplate="{CurrentPageReport} <span class='pg-text'> Pg </span> {JumpToPageDropdown} {totalPages} {RowsPerPageDropdown} "
rowsPerPageTemplate="5,10,15"
scrollable="true"
paginatorPosition="bottom"
>
我想在 paginatorTemplate 中使用 {totalPages}。
问题:我怎样才能做到这一点?
最佳答案
这就是我使用 Jquery 并使用 widgetVar
使用 getPaginator()
访问 Paginator
对象的方法。
<p:dataTable id="datatableid" widgetWar="myTableWidget"
paginatorTemplate="{CurrentPageReport} <span class='pg-text'> Pg </span> {JumpToPageDropdown} <div class='pg-temp-total'> </div> {RowsPerPageDropdown} "
...>
...
</p:dataTable>
把这个脚本放在表后面
<script type="text/javascript">
$('.pg-temp-total').text(PF('myTableWidget').getPaginator().cfg.rowCount);
</script>
这是我现在想到的一个解决方案,这是一种不寻常的方式,但它完成了工作。
关于jquery - 如何在 paginatorTemplate 中使用 {totalPages}?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27896696/