在 p:rowEditor 中调用取消的自定义侦听器

发布于 2024-11-14 03:47:30 字数 183 浏览 2 评论 0原文

当在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

拥醉 2024-11-21 03:47:30

尝试像 (JSF2 + Primefaces 2.2.1) ...

<p:column headerText="Test">
    <p:rowEditor>
        <p:ajaxStatus oncomplete="#{yourBean.yourHandleMethod()}"></p:ajaxStatus>
    </p:rowEditor>
</p:column>

Try like (JSF2 + Primefaces 2.2.1) ...

<p:column headerText="Test">
    <p:rowEditor>
        <p:ajaxStatus oncomplete="#{yourBean.yourHandleMethod()}"></p:ajaxStatus>
    </p:rowEditor>
</p:column>
甜点 2024-11-21 03:47:30

恐怕此功能无法开箱即用。 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文