如何在 f:ajax 之后调用过滤器
在我的 p:datatable 中,有一个名为“分辨率”的列,由复选框和文本组成。如果选中该框,则文本为“已解决”;如果未选中该框,则文本为“未解析”。我还为此列定义了一个过滤器框,因此仅显示已解决或未解决的条目。 如果我过滤“已解决”,然后取消选中该框,该条目现在为“未解决”,但它仍然显示。它不应该,因为它不再满足过滤器。我的问题是如何强制 filter() 在最后一个 f:ajax 渲染后执行?
这是我的代码片段:
<p:dataTable id="measurementHistoryTableId"
value="#{measurements.measurementHistoryList}"
var="meas3"
dynamic="true">
<p:column id="resolutionColumn"
filterBy="#{meas3.resolution}"
filterOptions="#{measurements.measurementHistoryOptions}"
sortBy="#{meas3.resolution}" >
<f:facet name="header">
<h:outputText value="#{msgs.MeasurementResolution}" />
</f:facet>
<h:selectBooleanCheckbox value="#{meas3.resolved}" >
<f:ajax event="click" execute="@all" render="resolutionId @this" />
</h:selectBooleanCheckbox>
<h:outputText id="resolutionId" value="#{meas3.resolution}" />
</p:column>
</p:dataTable>
我尝试了 render=@all,但这没有帮助。 render=@form 给我 jQuery.datepicker 未定义。我尝试将 'onclick=widget_measurementHistoryTableId.filter()' 添加到 'h:selectBooleanCheckbox' ,但它会导致过滤器在执行 'f:ajax' 之前触发。
感谢您能给我的任何帮助。 平
In my p:datatable, there is a column named Resolution, consisting of a check box and text. If the box is checked, the text is Resolved, If the box is not checked, then text is Unresolved. I also have a filter box defined for this column so only Resolved or Unresolved entries are shown.
If I filter on Resolved, then uncheck the box, the entry is now Unresolved, but it is still showing up. It shouldn't, because it no longer satisfies the filter. My question is how do I force filter() to execute after the last f:ajax render ?
Here is my code snipet:
<p:dataTable id="measurementHistoryTableId"
value="#{measurements.measurementHistoryList}"
var="meas3"
dynamic="true">
<p:column id="resolutionColumn"
filterBy="#{meas3.resolution}"
filterOptions="#{measurements.measurementHistoryOptions}"
sortBy="#{meas3.resolution}" >
<f:facet name="header">
<h:outputText value="#{msgs.MeasurementResolution}" />
</f:facet>
<h:selectBooleanCheckbox value="#{meas3.resolved}" >
<f:ajax event="click" execute="@all" render="resolutionId @this" />
</h:selectBooleanCheckbox>
<h:outputText id="resolutionId" value="#{meas3.resolution}" />
</p:column>
</p:dataTable>
I tried render=@all, but that didn't help. render=@form gives me jQuery.datepicker undefined. I tried to add 'onclick=widget_measurementHistoryTableId.filter()' to the 'h:selectBooleanCheckbox' , but it causes the filter to fire before the 'f:ajax' is executed.
Thanks for any help you could give me.
Binh
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道 primefaces 过滤是如何工作的,但是,如果
onclick=widget_measurementHistoryTableId.filter()
工作并且您只是希望它在 ajax 事件之后触发,您可以这样做:定义
reapplyFilter
js 函数:I don't know how primefaces filtering works but, if the
onclick=widget_measurementHistoryTableId.filter()
works and you jsut want it to be fired after the ajax event, you can do it like this:And then define the
reapplyFilter
js function: