call a custom listener for cancel in p:rowEditor

做~自己de王妃 提交于 2020-07-10 15:02:43

问题


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 ?


回答1:


Try like (JSF2 + Primefaces 2.2.1) ...

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



回答2:


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.



来源:https://stackoverflow.com/questions/6248933/call-a-custom-listener-for-cancel-in-proweditor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!