简体   繁体   English

使用分页更新primefaces datagrid上页面的更新组件

[英]Update component at change of page on primefaces datagrid with pagination

I have a datagrid with pagination. 我有一个带分页的数据网格。 When I change the page I want to update some components in the page, but I don't know how to get the event. 当我更改页面时,我想更新页面中的某些组件,但我不知道如何获取该事件。 Some code: 一些代码:

<p:panelGrid id="buttons">
  <p:commandLink value="Link1" action="#{myBean.method1}" disabled="#{myBean.boolean1}" />
  <p:commandLink value="Link2" action="#{myBean.method2}" disabled="#{myBean.boolean2}" />
</p:panelGrid>
<p:dataGrid var="myVar" paginator="true" value="#{myBean.listOfObjects}">
  ...
  ...
</p:dataGrid>

I want something like update="buttons" in the dataGrid, so when the page changes, update the buttons depending on disabled="" attribute of the buttons, is it possible? 我想在dataGrid中使用类似update="buttons"东西,所以当页面改变时,根据按钮的disabled=""属性更新按钮,是否可能?

Greetings. 问候。

Finally, instead of <p:dataGrid ... /> i used <p:dataTable ... /> with <p:ajax ... /> inside, this is my code: 最后,我使用<p:dataTable ... /><p:ajax ... />代替<p:dataGrid ... /> ,这是我的代码:

<p:dataTable var="myVar" paginator="true" rows="1" value="#{myBean.listOfObjects}">
  <p:ajax event="page" update="buttons" listener="#{myBean.update}" />
  ...
  ...
</p:dataTable>

And update method: update方法:

public void update(PageEvent event) {
  int var = event.getPage();
  ...
  (update components values of dataTable and buttons using var)
  ...
}

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

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