简体   繁体   English

如何使用支持 bean 完全控制 primefaces p:dataGrid 分页?

[英]how to have full controll of primefaces p:dataGrid pagination with the backing bean?

I have ap:dataGrid of primefaces that has a pagination on top of the dataGrid.我有 ap:dataGrid 的primefaces,它在dataGrid 顶部有一个分页。

my goal is to have full control of the pagination buttons so when I click to have some action method associated with it.我的目标是完全控制分页按钮,因此当我单击以获取与其相关联的某些操作方法时。 is there anyone that can explain to me.有谁能给我解释一下。 this is my idea.这是我的想法。

 <p:dataGrid var="car" value="#{tableBean.cars}" columns="3"  
    rows="12" paginator="true"  
    paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
   > 

when I click one of {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}当我点击 {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} 之一时

to be captured from the backing bean so I can do some extra activity prior displaying the page.从支持 bean 中捕获,这样我就可以在显示页面之前做一些额外的活动。

if anyone also know how to use getPaginator() client Api and give me an example would be great on their documentation it mentions it but without any snippets of code.如果有人也知道如何使用 getPaginator() 客户端 Api 并给我一个例子,那么在他们的文档中会很好地提到它,但没有任何代码片段。

Thank you.谢谢你。

Primefaces has a page event you can use in a <p:ajax/> as you would any other event like so Primefaces 有一个page事件,你可以在<p:ajax/>就像你在任何其他事件一样

 <p:ajax event="page" listener="#{tableBean.myListener}" />

Attach this ajax listener to your datatable to achieve the results you want将此ajax侦听器附加到您的数据表以实现您想要的结果

Alternatively, you could implement the extra processing load() method in the primefaces LazyDataModel , see an example here或者,您可以在 primefaces LazyDataModel实现额外的处理load()方法,请参阅此处的示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM