【问题标题】:primefaces clearFilters function clears filters but does not start filter eventsprimefaces clearFilters 函数清除过滤器但不启动过滤器事件
【发布时间】:2012-12-13 08:32:45
【问题描述】:

我在 <p:dataTable> 中使用延迟加载并尝试使用 Widget 清除过滤器:PrimeFaces.widget.DataTable.clearFilters()
尽管此函数会清除所有过滤器,但过滤器事件不会启动。因此Map<String, String> 过滤器值保持不变,数据表不会更新。

public List<LazyModelInterface> load(int startingAt, 
       int maxPerPage, 
       String sortField, 
       SortOrder sortOrder, 
       Map<String, 
       String> filters)

【问题讨论】:

  • 请提供更多信息:哪个PF版本,Bean的范围,来自site.xhtml的sn-p。干杯!

标签: datatable primefaces lazy-loading


【解决方案1】:

如何使用一些f:ajax(例如h:commandButton)和指向将执行以下代码的方法的侦听器

public void resetFilters(AjaxBehaviorEvent ev) {
    DataTable dataTable = (DataTable) FacesContext.getCurrentInstance().getViewRoot()
            .findComponent("myFormId:myTableId");
    if (dataTable != null) {
        dataTable.reset();
    }
}

【讨论】:

  • 非常感谢,但我希望其余部分保持不变。 Datatable 中有一个标签为 filterEvent,默认值为“keyup”。我相信因为 clearFilters() 不会启动 filterEvents。到目前为止,更改 filterEvent 没有奏效。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-01-29
  • 1970-01-01
  • 1970-01-01
  • 2014-01-04
  • 1970-01-01
  • 2017-12-30
相关资源
最近更新 更多