Date Range Filter in Data Table

UI Components for JSF
itssaurav2004
Posts: 2
Joined: 15 Nov 2010, 21:47

19 Nov 2010, 12:54

Is there any way to apply a filter which is range of date?

Suppose i want to display only those rows which has a manufacturing date between Jan 1, 2010 to Jan 15, 2010.

persapiens
Posts: 17
Joined: 02 Sep 2010, 17:27

18 Aug 2011, 21:15

I have the same issue too :(
primefaces 3.3.1, mojarra 2.1.7, tomcat 7.0.27, java sun 1.6.0_24, netbeans 7.1.1

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

18 Aug 2011, 21:40

No but you can implement your own filtering by placing input yourself on column header.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

18 Aug 2011, 21:59

Filtering enhancements are pending, stay tuned.

cbmyers
Posts: 53
Joined: 20 Oct 2010, 14:56

22 Aug 2011, 15:51

Optimus,

do you have an example i can see of this:
No but you can implement your own filtering by placing input yourself on column header.
Thanks,

Chris
- Chris
PrimeFaces 3.0M1
Eclipse Indigo (with Tomcat 7.0.14)
Java 1.6
JSF 2.0 (Mojarra 2.0.4)
hibernate 3.5.5

rweaver
Posts: 6
Joined: 13 Oct 2011, 18:18

13 Oct 2011, 18:26

Any update on date range filtering for DataTable ?

I've been able to put in a "filterBy" and both the textbox and dropdown approach let me key on a specific date, although both seem like a bit of a kludgy way to select a date.

What I'd really like to do is have the filter give a nice date selector, and/or a date range selector (similar to what you typically have on airline search sites for example).

kingdan
Posts: 44
Joined: 06 May 2011, 19:55
Location: Aracaju, Brazil

21 Jan 2012, 12:52

cbmyers wrote:Optimus,

do you have an example i can see of this:
No but you can implement your own filtering by placing input yourself on column header.
Thanks,

Chris
SOLUTION:

Code: Select all

.calendarFilter .ui-inputfield
            {
                width:70px; !important;
                margin: 0 0.2em; !important;
            }

<f:facet name="header">
    Date
    <div style="display: block;  width: 90%; margin: auto;">
          <p:calendar id="firstDate" styleClass="calendarFilter" value="#{bean.minDate}">
                  <p:ajax event="dateSelect" listener="#{bean.filterDataTable()}" update="dataTableId" />
          </p:calendar>
           -
          <p:calendar id="lastDate" styleClass="calendarFilter" value="#{bean.maxDate}">
                  <p:ajax event="dateSelect" listener="#{bean.filterDataTable()}" update="dataTableId" />
          </p:calendar>
    </div>
</f:facet>
Notes:
1) It's important to wrap those calendars into a div with style=block for displaying the components bellow the header text.
2) Necessary apply style classes in order to display the components harmoniously.
3) I suggest specifying the column's width. (personally i like 200px in this case)
3) Div's width is set to 90% for making available the most possible space for the sorting click at the header cell. (when using sortBy)
Last edited by kingdan on 21 Jan 2012, 13:57, edited 3 times in total.
Move Fast, Break Things!

kingdan
Posts: 44
Joined: 06 May 2011, 19:55
Location: Aracaju, Brazil

21 Jan 2012, 13:50

optimus.prime wrote:No but you can implement your own filtering by placing input yourself on column header.
I read the manual but i couldn't figure out how to implement the filter method on javascript.

I didn't understand this:
"Filter located at header is a global one applying on all fields, this is implemented by calling client
side api method called filter(), important part is to specify the id of the input text as globalFilter
which is a reserved identifier for datatable."
Move Fast, Break Things!

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

22 Jan 2012, 02:44

kingdan wrote:SOLUTION:

Code: Select all

.calendarFilter .ui-inputfield
            {
                width:70px; !important;
                margin: 0 0.2em; !important;
            }

<f:facet name="header">
    Date
    <div style="display: block;  width: 90%; margin: auto;">
          <p:calendar id="firstDate" styleClass="calendarFilter" value="#{bean.minDate}">
                  <p:ajax event="dateSelect" listener="#{bean.filterDataTable()}" update="dataTableId" />
          </p:calendar>
           -
          <p:calendar id="lastDate" styleClass="calendarFilter" value="#{bean.maxDate}">
                  <p:ajax event="dateSelect" listener="#{bean.filterDataTable()}" update="dataTableId" />
          </p:calendar>
    </div>
</f:facet>
Notes:
1) It's important to wrap those calendars into a div with style=block for displaying the components bellow the header text.
2) Necessary apply style classes in order to display the components harmoniously.
3) I suggest specifying the column's width. (personally i like 200px in this case)
3) Div's width is set to 90% for making available the most possible space for the sorting click at the header cell. (when using sortBy)
I have been doing something very similar to this and this works as designed for me, and i had no need to ask Optimus.Prime for dataTable to do something like this, especially, since I use LazyDataModel a lot through JSF/Primefaces web app that I'm developing; per my experience, p:dataTable filterBy and sortBy does not work well with LazyDataModel, so i had to develop my own solution, and it works for me. :)
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

tehackio
Posts: 20
Joined: 04 Feb 2012, 14:55

04 Feb 2012, 15:04

Hi, can you share your solution?
I'm working with lazydatamodel. The filter works well with strings, but I wanna put date interval, autocomplete, checks.
smithh032772 wrote:
kingdan wrote:SOLUTION:

Code: Select all

.calendarFilter .ui-inputfield
            {
                width:70px; !important;
                margin: 0 0.2em; !important;
            }

<f:facet name="header">
    Date
    <div style="display: block;  width: 90%; margin: auto;">
          <p:calendar id="firstDate" styleClass="calendarFilter" value="#{bean.minDate}">
                  <p:ajax event="dateSelect" listener="#{bean.filterDataTable()}" update="dataTableId" />
          </p:calendar>
           -
          <p:calendar id="lastDate" styleClass="calendarFilter" value="#{bean.maxDate}">
                  <p:ajax event="dateSelect" listener="#{bean.filterDataTable()}" update="dataTableId" />
          </p:calendar>
    </div>
</f:facet>
Notes:
1) It's important to wrap those calendars into a div with style=block for displaying the components bellow the header text.
2) Necessary apply style classes in order to display the components harmoniously.
3) I suggest specifying the column's width. (personally i like 200px in this case)
3) Div's width is set to 90% for making available the most possible space for the sorting click at the header cell. (when using sortBy)
I have been doing something very similar to this and this works as designed for me, and i had no need to ask Optimus.Prime for dataTable to do something like this, especially, since I use LazyDataModel a lot through JSF/Primefaces web app that I'm developing; per my experience, p:dataTable filterBy and sortBy does not work well with LazyDataModel, so i had to develop my own solution, and it works for me. :)

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Google [Bot] and 48 guests