加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ajax – DataTable .filter()和clearFilters()隐藏消息p:messag

发布时间:2020-12-16 02:54:25 所属栏目:百科 来源:网络整理
导读:我使用时的问题: p:growl id="growl" autoUpdate="true" / 要么 p:messages id="messages" autoUpdate="true" / 当我有错误消息,并且一旦我使用清除过滤器或重新过滤primefaces数据表,如: p:commandButton value="do somthing and re-filter" oncomplete="
我使用时的问题:

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

要么

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

当我有错误消息,并且一旦我使用清除过滤器或重新过滤primefaces数据表,如:

<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是真的,所以ajax调用过滤器被触发并返回没有消息所以这个调用清除消息,如果我使autoUpdate =“false”将是一个解决方案,但我需要它所以我不想把它设置为假.

解决方法

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

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读