【问题标题】:Updating more than one cell value in Primefaces DataTable [duplicate]在 Primefaces DataTable 中更新多个单元格值 [重复]
【发布时间】:2017-01-08 03:23:03
【问题描述】:

使用example from Primefaces DataTable Edit,我将年份列改为显示价格,并添加了一个显示计算总价的页脚。

<f:facet name="footer">
    <h:outputText id="carstotal" value="Total: #{dtEditView.totalSales}" />
</f:facet>

有没有办法在更改任何价格单元时也更新这个总值?提前谢谢你。

【问题讨论】:

  • 你尝试添加一个ajax事件keyup ?!?
  • 我只使用了 EditView.java 中的 onCellEdit() 方法,我在其中放置了 RequestContext.getCurrentInstance().update("form:cars2:carstotal");在 if 语句中,但没有成功... cartotal 是页脚元素的 id。
  • 我也从可能的重复中尝试了该示例,但这并不完整。 refreshFooter();示例中未定义。并且将 oncomplete="" 设置为 会使 DataTable 在单击和修改单元格时无法正确呈现......无论如何,这个问题有解决方案吗?

标签: jsf jsf-2 primefaces datatable


【解决方案1】:

经过一些变通方法后,解决方案是在&lt;h:form&gt; 标记内的cars.xhtml 中包含以下两条线:

<p:remoteCommand name="onCellEdit" update=":form:msgs :form:cars2:carstotal" />

<p:ajax event="cellEdit" listener="#{dtEditView.onCellEdit}" oncomplete="onCellEdit()" />

h:outputText 会在更改表格单元格时更新其值,但即使在 update=":form:msgs :form:cars2:carstotal" 中声明,消息现在也不会出现在右上角

【讨论】:

  • 我不小心删除了我的评论,但最好将 Q 标记为重复而不是新答案。因为它是 100% 重复的...
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-09-15
  • 1970-01-01
  • 2011-04-13
  • 1970-01-01
相关资源
最近更新 更多