0

I have a dataTable with filters on columns and option to delete a row. When the table is in intial state, if I delete row, the table is updated. If I apply the filter, and delete one of shown rows, the result of the filtering remains, until I refresh the page or change the filter.

Here is the code:

<h:form id="form">
    <p:dataTable id="tdataTable" var="tdata" value="#{oemModel.models}" widgetVar="oemModelsTable" editable="true" editMode="cell"
                scrollable="true" scrollHeight="500" paginator="true" rows="15" 
                             emptyMessage="No tdatas found with given criteria" filteredValue="#{oemModel.filteredOemModels}">
    </p:dataTable>

               <p:dialog id="deleteModelDialog" header="Delete " widgetVar="deleteDialog" appendTo="@(body)" showEffect="fade" hideEffect="fade" height="150" width="350" modal="true" resizable="false" >
                    <h:panelGroup id="deleteModelPanel">
                        <div align="center">
                            <h:outputText value="Are you sure?" />
                            <p>
                                <h:panelGrid columns="2">
                                    <p:commandButton value="Yes" icon="ui-icon-check" onclick="PF('waitDialog').show();deleteModel();" />
                                    <p:commandButton value="No" icon="ui-icon-close" onclick="PF('deleteDialog').hide()"/>
                                </h:panelGrid>
                            </p>
                        </div>
                    </h:panelGroup>
                </p:dialog>

                <p:remoteCommand name="deleteModel" update="tdataTable" actionListener="#{bBean.deleteModel}" oncomplete="PF('waitDialog').hide();PF('deleteDialog').hide();"/>
 </h:form>

And in backingBean, I'm deleting it from database, and loading data again:

public void deleteModel() {
        try {
            service.deleteOemModel(selectedModel.getId());
            models= service.getOemModels();
        } ...
    }

where the models is the binded list.

Any hints? I have tried to change the update attribute on remotecommand, to update the whole form, but nothing helps.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Djordje Ivanovic
  • 4,151
  • 4
  • 27
  • 49

1 Answers1

2

You have to filter again, because the filter is cached. As described in this example Ajax update doesn't work, when using filter on p:dataTable you should try:

<p:remoteCommand name="deleteModel" update="tdataTable" actionListener="#{bBean.deleteModel}" oncomplete="PF('waitDialog').hide();PF('deleteDialog').hide(); PF('oemModelsTable').filter()"/>

Try it with PF and without, I'm not into Primefaces in this moment :D

Community
  • 1
  • 1
kdoteu
  • 1,527
  • 1
  • 20
  • 26