简体   繁体   中英

Primefaces datatable column update

I have a Primefaces datatable and what I want to do is after user clicks to "removeItemsFromList" button, program will update datatable records. Datatable is updating but my checkbox column doesn't. After I click to button, records are updating but selected checkboxes still remains selected. I want them to reset. I mean I want all datatable to reset.Is there any easy way to do this?

My commandbutton;

<p:commandButton value="removeItemsFromList"
                         actionListener="#{myController.sendToArchive()}"
                         update="myDatatableId"
                         icon="ui-icon-folder-open"/>

My datatable column;

<p:column headerText="">
                <p:selectBooleanCheckbox>
                    <p:ajax event="change" listener="#{myController.addToSelectionList(iss)}"/>
                </p:selectBooleanCheckbox>
            </p:column>

You can achieve this functionality using the resetInput component:

<p:commandButton value="removeItemsFromList"
                     actionListener="#{myController.sendToArchive()}"
                     update="myDatatableId"
                     icon="ui-icon-folder-open">
    <p:resetInput target="myDatatableId" /> 
</p:commandButton> 

For other solutions i can suggest:

A. Javascript / JQuery

B. Binding the value of the checkbox to a bean variable, and set it to false after each update

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM