如何在p:dataGrid中制作自动分页器 [英] how to make automatic paginator in p:dataGrid
本文介绍了如何在p:dataGrid中制作自动分页器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使我的<p:dataGrid>
分页自动进行.无需使用下一步按钮,只需几秒钟即可移至下一页.
I would like to make my <p:dataGrid>
pagination automatic. Without using the next button, move to the next page in few seconds.
<p:dataGrid id="cars" var="of" value="#{infoBaseOfVals.listinfoBaseOf}"
columns="2" rows="4" layout="grid" paginator="true" cellpadding="10"
cellspacing="20px" scrolling="false" responsive="true" type="unordered" itemType="none"
paginatorTemplate="Nombre OFs : #infoBaseOfVals.listinfoBaseOf.size()} OFs {CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="2,4,8,16,24,32,40,48,56,64,72,80">
我该如何实现?
推荐答案
对于PrimeFaces的最新版本(至少为6.0,但也许还有之前的版本),您可以使用一些JavaScript来实现.将widgetVar属性设置为您的dataGrid并添加如下内容:
For recent versions of PrimeFaces (at least 6.0, but maybe also some before) You can achieve that with a little javascript. Set the widgetVar attribute to your dataGrid and add something like this:
var myVar = setInterval(myTimer, 5000);
myDataGridPaginator = PF('myDatagridWidgetVar').getPaginator();
function myTimer() {
myDataGridPaginator().setPage(myDataGridPaginator.cfg.page + 1);
}
对于较旧的PrimeFaces版本(如果无法使用),请参见其他答案
For older PrimeFaces version (if this does not work) see the other answer
这篇关于如何在p:dataGrid中制作自动分页器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文