在 p:rowEditor 中调用取消的自定义侦听器
当在 primefaces rowEditor 组件中单击取消按钮时,我一直尝试调用自定义侦听器。但我无法找到正确的属性来执行此操作。
取消按钮的问题在于,当数据表中已存在该行时,如果我尝试向数据表动态添加新行并单击取消按钮[如果我认为不需要],它可以正常工作,当应该删除空行时,空行会显示在数据表中。
你能帮我一下吗?
I have been trying to call a custom listener when the cancel button is clicked in the primefaces rowEditor component. But I am not able to find the correct attribute to do this.
The problem with the cancel button is that it works fine when the row is already present in the dataTable, if I try to add a new row dynamically to the dataTable and click on the cancel button [ if I think that it is not required ], the empty row is shown in the dataTable, when the empty row should be deleted.
Would you please help me out ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试像 (JSF2 + Primefaces 2.2.1) ...
Try like (JSF2 + Primefaces 2.2.1) ...
恐怕此功能无法开箱即用。 rowEditor 组件内置了与数据表的集成以及它自己的事件和侦听器,用于编辑单个现有行。 rowEditor 组件的取消按钮具有切换 Primefaces 列组件的输出和输入面的唯一功能。
如果您擅长 jQuery,您可以通过取消按钮类
jQuery('.ui-icon-close')
查找 DOM 元素并分配自定义 javascript 事件来破解该功能但这在有多行的数据表中可能会出现问题,并且如果选择“取消”,听起来好像您想删除空白行。更好的方法是创建一个添加新按钮来显示带有表单的对话框。通过对话框中的表单提交可以将必要的行添加到您的数据表中。
I am afraid this functionality isn't available out of box. The rowEditor component has built in integration to a dataTable and its own events and listeners for editing a single existing row. The cancel button of the rowEditor component has the sole functionality of toggling the output and input facets of the Primefaces column components.
If you are good at jQuery you may be able to hack the functionality in by finding the DOM element by the cancel button class,
jQuery('.ui-icon-close')
and assigning a custom javascript event listener but this could be problematic in a dataTable where there are multiple rows and it sounds as if you would like to delete a blank row if Cancel is selected.A better approach is create an Add New button that displays a dialog with a form. Submitting through the form in the dialog can add the necessary row to your dataTable.