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 .
相关问题
- java.lang.NullPointerException at java.io.PrintWri
- h:selectOneMenu in p:dataTable doesn't submit
- PrimeFaces block UI does not work when the compone
- primefaces orderlist not getting updated with the
- How to address the surrounding naming container in
相关文章
- How to override primefaces component api class wit
- Getting value from dynamically created inputText
- dataTable sorting problem (JSF2.0 + primefaces)
-
limiting to 2 Mb
-
how to remove upload cancel button from
- JSF 2 template partial update [duplicate]
-
Primefaces
doesn't work
- Datatable does not sort elements in primefaces
You should be able to do this like this:
If you are not filtering layzily, then you have to provide and implement a filterFunction
I know this question was asked a while ago but here is my solution with Primefaces 5.2
I hope it can help anybody
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:
h:inputHidden
) in the filter facet to hide the default filter input fieldp:calendar
in the header facetonstart
replace the value of your hidden input by the value of the calendar. Inoncomplete
use the client side API to filter your datatableNote 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)Edit: Actually, PrimeFaces calendar supports datetime in
mode="datetime"
. I wasn't aware of this. See https://code.google.com/p/primefaces/issues/detail?id=648I have the requirement too on my site. However I have a different implementation from @stg. By the time of this writing, I'm using Primefaces 5.0. Here is the piece of work that does the job:
XHTML site
Java site
Site note
DateUtils.truncateEquals()
because my date column contains timestamp. This is to ensure that I'm filtering on the particular date regardless of timestamp. If my input is date only then table view would be empty.<p:ajax event="change" ...>
is needed to reset table view when the filter input is remove. I wasn't sure whether this is the correct way to handle this, I'm currently using it until I find a better one.