Primefaces 3.4删除行后,Datatable无法正确刷新 [英] Primefaces 3.4 Datatable doesn't refresh correctly after delete row

查看:182
本文介绍了Primefaces 3.4删除行后,Datatable无法正确刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个组件,每行都有一个删除按钮。当单击删除按钮时,将会调用一个confirm对话框,单击对话框上的是后,行将被删除。

I have created a component that has a delete button per row. When the delete button is clicked, a confirmDialog will be called and upon clicking 'Yes' on the dialog, the row will be deleted.

该表刷新,但在UI上删除错误的行。在bean上,正确的记录被删除。在UI方面,删除的行始终是最后一行,无论您选择删除哪一行。

The table refreshes, but the wrong row is removed on the UI . On the bean, the correct record is deleted. On the UI side, the row removed is always the last row, no matter which row you pick to delete.

删除按钮位于datatable本身,confirmDialog是位于可数据之外,但位于同一形式内。

The Delete button is in the datatable itself and the confirmDialog is located outside the datatable but within the same form.

有人知道有什么问题吗?

Does anybody know what is wrong?

<p:commandButton icon="ui-icon ui-icon-trash"
        update="@form"
        oncomplete="del_confirmation.show()"
        value="Delete" 
        immediate="true">
       <f:setPropertyActionListener value="#{item}" 
         target="#{Bean.recToDelete}"/>
</p:commandButton>


<p:confirmDialog widgetVar="del_confirmation"
message="Confirm Delete?"
header="Delete Dialog" showEffect="explode"
hideEffect="explode" modal="true">
<div align="center">
    <p:commandButton id="delBtn"
        icon="ui-icon ui-icon-check"
        value="Yes"
        actionListener="#{Bean.deleteRecord()}"
        update="@form"
        oncomplete="del_confirmation.hide()" 
        immediate="true"
        ajax="true" />
    <p:commandButton
        icon="ui-icon ui-icon-cancel" 
        value="No"
        onclick="del_confirmation.hide()" />
</div></p:confirmDialog>


推荐答案

显示您的数据表代码,只有 p:datatable ...

Show your datatable code, only the p:datatable...

表中没有缓存,也尝试删除 immediate 并使用 action =#{myBean.myDeleteMethod(item)} f:setPropertyActionListener $ c>

There is no caching in the table, also try removing the immediate and replace the f:setPropertyActionListener by using action="#{myBean.myDeleteMethod(item)}"

这篇关于Primefaces 3.4删除行后,Datatable无法正确刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆