5

在我的应用程序中,dialog我在每一列中显示了dataTable一个复选框来选择相应的行。在底部dialog我调整了两个按钮,一个用于显示选定的行,另一个用于重置数据表意味着取消选择选定的行。

.xhtml 代码如下:

<p:dialog id="popUp" header="Activity Detail" widgetVar="popUpWidget" 
 showEffect="fade" hideEffect="explode" resizable="false" modal="true">
<h:panelGrid>
    <p:row>
        <p:column colspan="2">
            <p:dataTable id="userListForAdminpopup" value="#{activityListController.activityUsers}" var="user"
                paginator="true" paginatorPosition="bottom" widgetVar="userListForAdminpopUp"
                paginatorTemplate="{FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
                rows="10" selection="#{activityListController.selectedActivityUsers}">

                <p:column headerText="#{adbBundle['fullName']}"
                    sortBy="#{user.lastName}" filterBy="#{user.fullName}"
                    filterMatchMode="contains" styleClass="userName">
                    <h:outputLabel value="#{user.firstName}" />
                </p:column>

                <p:column selectionMode="multiple" />
            </p:dataTable>
        </p:column>
    </p:row>
    <p:row>
        <p:column colspan="2">
            <h:panelGroup layout="block">
                <p:commandButton value="Update" oncomplete="confirmation.show()"/>
                <p:commandButton value="Reset"/>
            </h:panelGroup>
        </p:column>
    </p:row>
</h:panelGrid></p:dialog>

单击重置按钮时,我想取消选择行。怎么做?

4

3 回答 3

13

我们可以p:dataTable使用取消选择行unselectAllRows()

<p:dataTable
    id="dataTableId"                             
    widgetVar="dtWidgetVar"
    value="#{myBean.items}"
    var="item"
    ....>
</p:dataTable>

<p:commandButton value="Reset" onclick="PF('dtWidgetVar').unselectAllRows()" />

从豆

PrimeFaces.current().executeScript("PF('dtWidgetVar').unselectAllRows()");
于 2014-07-24T09:29:25.753 回答
3

你试试:

<p:commandButton value="Reset" update="userListForAdminpopup" process="@this" actionListener="#{activityListController.hand}"/>

豆:

public void hand(){
   selectedActivityUsers = new ActivityUsers(); // Type of element of list
}
于 2013-04-11T09:39:31.287 回答
0

试试这个:

DataTable dataTable = (DataTable) FacesContext.getCurrentInstance().getViewRoot().findComponent("form:dataTable"); 
dataTable.reset();
于 2021-10-21T12:55:45.727 回答