5

我的主要 jsf 包括 2 个 jsf,其中每个都有一个带有过滤选项的表。

这是主要的一个简短示例:

  <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" />

问题是我需要在更改 2 个表之间的视图时删除过滤器我不能通过 clearFilters 使用客户端,因为我有 2 个表:

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

所以我在想最好的地方是通过handle方法在服务器端,但是过滤器列表是空的,表格也是

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

如何重置过滤器?

谢谢

4

3 回答 3

1

我的会话中有 2 个数据表。我不明白原因,但是当我使用dt1.reset()它时,它们都会重置。

我试过了

dt1 = new DataTable();

它解决了我的问题。

注意:dt1.reset()当我尝试使用 1 个数据表时有效。

于 2016-02-10T14:08:41.987 回答
0

You can use either of the following on that datatable that you have:

  1. dt1..setFilters(null); Will get rid of the datatable filter values

  2. dt1.reset() will also reset the datatable to a virgin state

于 2013-03-22T03:13:01.663 回答
0

使用Primefaces 当前助手(6.2 版)在服务器端执行 clearFilters,如下所示:

PrimeFaces current = PrimeFaces.current();
current.executeScript("PF('dataTableWidget').clearFilters()");
于 2019-01-24T19:14:09.233 回答