Primefaces数据表(日期列)按日历过滤 [英] Primefaces Datatable (date column) Filter by calendar

查看:80
本文介绍了Primefaces数据表(日期列)按日历过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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 方面
  • 中放入p:calendar
  • 将dateSelect事件添加到您的日历中.在onstart中,将隐藏的输入的值替换为日历的值.在oncomplete中,使用客户端API过滤数据表
  • 编写您的自定义过滤器函数,以根据需要比较对象值和过滤器值
  • 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. In oncomplete 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屋!

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