Primefaces数据表(日期列)按日历过滤 [英] Primefaces Datatable (date column) Filter by calendar
问题描述
我正在使用PF 5.1.我想通过此处的日历集primefaces calendar过滤Primefaces数据表(日期列). 是否有可能 ? -请帮助任何人.
I am using PF 5.1. I want to filter Primefaces datatable (date column) by calendar set primefaces calendar here . Is it possible ? -Please help anybody .
推荐答案
对于较旧的PrimeFaces版本,该解决方案必须像此答案中那样实现,对于较新版本,另一个答案中应包含解决方案.
For older PrimeFaces versions the solution has to be implemented like in this answer, for newe versions the other answer contains the solution.
基本上,这可以通过以下方式实现:
Basically, this can be achieved like this:
- 在 filter 方面使用隐藏的输入字段(例如
h:inputHidden
)来隐藏默认的过滤器输入字段 - 在 header 方面 中放入
- 将dateSelect事件添加到您的日历中.在
onstart
中,将隐藏的输入的值替换为日历的值.在oncomplete
中,使用客户端API过滤数据表 - 编写您的自定义过滤器函数,以根据需要比较对象值和过滤器值
p:calendar
- use a hidden input field (like
h:inputHidden
) in the filter facet to hide the default filter input field - put a
p:calendar
in the header facet - add a dateSelect event onto your calendar. In
onstart
replace the value of your hidden input by the value of the calendar. Inoncomplete
use the client side API to filter your datatable - write your custom filter function to compare the object value and the filter value as required
请注意,p:calendar
仅用于客户输入日期.如果您在过滤器功能中也需要正确的时间,请考虑使用其他TimePicker(例如
Note that the p:calendar
is meant to be for client input of a date only. If you also need the correct time in your filter function consider using an additional TimePicker (e.g. http://www.primefaces.org/showcase-ext/sections/timePicker/basicUsage.jsf)
实际上,PrimeFaces日历在mode="datetime"
中支持日期时间.我没有意识到这一点.请参见 https://code.google.com/p/primefaces/issues /detail?id = 648
Actually, PrimeFaces calendar supports datetime in mode="datetime"
. I wasn't aware of this. See https://code.google.com/p/primefaces/issues/detail?id=648
这篇关于Primefaces数据表(日期列)按日历过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!