DataTable .filter()和clearFilters()隐藏消息p:messages和p:growl [英] DataTable .filter() and clearFilters() hides messages p:messages and p:growl

查看:97
本文介绍了DataTable .filter()和clearFilters()隐藏消息p:messages和p:growl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用时出现的问题:

<p:growl id="growl" autoUpdate="true" />

<p:messages id="messages" autoUpdate="true" />

出现错误消息时,一旦对明文数据表使用清除过滤器或重新过滤器,如:

When I have error message, and once I use clear filters or re filter for primefaces datatable like :

<p:commandButton value="do somthing and re-filter" oncomplete="PF('testTable').filter()"/>

<p:commandButton value="do somthing and clear filter" oncomplete="PF('testTable').clearFilters()"/>

<p:dataTable id="table" widgetVar="testTable" value="#{myMB.data}">
</p:dataTable>

消息被隐藏了,因为autoUpdate为true,所以如果我创建了autoUpdate="false",但是我需要它,那么我将取消过滤器的ajax调用,并且不返回任何消息,因此此调用清除消息将是一种解决方案.不想将其设置为false.

The messages got hidden, that because the autoUpdate is true, so ajax call for filter fired and return with no messages so this call clear messages, will be a solution if I make autoUpdate="false" but I needed it so I don't want to set it to false.

推荐答案

解决方案是将ajax过滤器事件添加到p:datatable:

Solution is to add ajax filter event to the p:datatable:

<p:dataTable id="table" widgetVar="testTable" value="#{myMB.data}">
    <p:ajax event="filter" ignoreAutoUpdate="true" />
    {...}
</p:dataTable>

这篇关于DataTable .filter()和clearFilters()隐藏消息p:messages和p:growl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆