单击确认对话框中的“是"按钮清除网格 [英] Clear grid on click of Yes button in confirmation dialog box

查看:72
本文介绍了单击确认对话框中的“是"按钮清除网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个JSF,其中具有删除网格的特定行的功能.我正在使用面板网格.单击删除按钮后,我单击确定时会出现一个确认对话框,应删除行并刷新网格.我可以删除该行,但是网格不会刷新或清除. 以下是我的JSF代码.任何帮助将不胜感激.

I have a JSF in which i have a functionality to delete a particular row of a grid. I am using panel grid. On click of delete button i get a confirmation dialog box on click of yes which the row should be deleted and the grid should be refreshed. I am able to delete the row however the grid does not get refreshed or clear. Below is my JSF Code. Any help will be appreciated.

<p:commandButton id="delete"
  icon="ui-icon ui-icon-trash"
  action="#{trafficExpenseItemsMBean.deleteTrafficExpenseItemRow}"
  onclick="setSelectedRowId('rowId',#{trafficSearchResult.id})"
  title="GDeleteButton">
  <p:confirm header="Delete Record"
    message="Are you sure about deleting this record?"
    icon="ui-icon-alert"/>
</p:commandButton>

<p:confirmDialog global="true" showEffect="fade">
  <p:commandButton title="GDelYesButton" value="Yes" styleClass="ui-confirmdialog-yes"/>
  <p:commandButton title="GDelNoButton" value="No"  onclick="PF('confirmation').hide()" styleClass="ui-confirmdialog-no" />
</p:confirmDialog>

推荐答案

如果我理解正确性,则需要返回托管bean中的数据,您需要使用给定的id调用该bean的某个函数,并且托管bean本身将处理操作.因此,在您从setSelectedRowId('rowId',#{trafficSearchResult.id})调用中设置rowId之后. 在确认按钮上,您需要调用适当的delete方法,并根据其小部件ID更新网格组件,例如:

if i understand correclty u back the data in a managed bean u need to call a certain function of that bean with the given id and the managed bean itself would handle the operation. so after u set the rowId from ur setSelectedRowId('rowId',#{trafficSearchResult.id}) call. on confirmation button u need to call the proper delete method, and update the grid component based on its widget id for example:

 <p:commandButton title="GDelYesButton" value="Yes" onclick="bean.removeItem()" oncomplete = "PF('datagrid_widget_id').update() PF('confirmation').hide()"/>

这篇关于单击确认对话框中的“是"按钮清除网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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