In my application in a dialog
I displayed a dataTable
in each column there are a check box to select corresponding row. At the bottom of dialog
I paced two
button one for display selected rows another for reset the datatable means to deselect the selected rows.
.xhtml code is given below:
<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>
I want to deselect the rows when click on reset button. How it can be done?
We can deselect p:dataTable
rows using unselectAllRows()
<p:dataTable
id="dataTableId"
widgetVar="dtWidgetVar"
value="#{myBean.items}"
var="item"
....>
</p:dataTable>
<p:commandButton value="Reset" onclick="PF('dtWidgetVar').unselectAllRows()" />
From the bean
PrimeFaces.current().executeScript("PF('dtWidgetVar').unselectAllRows()");
You try:
<p:commandButton value="Reset" update="userListForAdminpopup" process="@this" actionListener="#{activityListController.hand}"/>
Bean:
public void hand(){
selectedActivityUsers = new ActivityUsers(); // Type of element of list
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With