Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reset dataTable filter via server side

My main jsf include 2 jsf’s where in each one of them there is a table with filtering option.

this is a short example from the main:

  <h:panelGroup id="b1">
                <p:commandButton
                    value="exe"
                    actionListener="#{bean.handle}"
                    rendered="#{bean.render}"
                    update=":mainForm:panel1,:mainForm:panel2">
                </p:commandButton>
            </h:panelGroup>
        </h:panelGrid>
    </p:panel>

    <ui:include src="table1.xhtml" />
    <ui:include src="table2.xhtml" />

The problem is that I need to remove the filters when changing the view between the 2 tables I can’t use the client side via clearFilters since I have 2 tables:

<p:commandButton
oncomplete="table1Widget.clearFilters() ????"

so I was thinking that the best place will on the server side via handle method but the filter list is empty and also the table

DataTable dt1 = (DataTable) FacesContext.getCurrentInstance().getViewRoot().findComponent("mainForm: .... ");

How can i reset the filters ?

Thanks

like image 822
angus Avatar asked Nov 12 '22 08:11

angus


1 Answers

I have 2 datatables at my session. I didn't understand reason but when i use dt1.reset() it resets both of them.

I tried

dt1 = new DataTable();

and it solved my problem.

Note: dt1.reset() works when i tried with 1 datatable.

like image 120
omerhakanbilici Avatar answered Nov 15 '22 11:11

omerhakanbilici