Question

I am using icefaces 3.2. I want to know how to make the filterbox of ace:datatable filter based on value range entered in the filter box. e.g for the datatable's price column which has double value, i want to enter a range in the filter box which is like ">1000" and the filter should filter it.

Was it helpful?

Solution

Ok, I see your Subject and your question are totally different. But as far to filter a "Date Based Expression" , Icefaces doesn't provide filtering support other than String format. So, here is a workaround that I did to get that done.

In you .xhtml markup :

  1. Add attribute constantRefilter= "true" for the corresponding ace data table.
  2. For the Date Column :

    <ace:column id="scanDateColumn" filterBy="#{row.scanDate}"
    filterValue="#{mainReport.scanDateFilter}" filterMatchMode="exact">
    <f:facet name="header">
    Scan Date
    <ace:dateTimeEntry id="scanDate" timeZone="#{mainReport.timeZone}"
    value="#{mainReport.scanCalenderDate}" pattern="MM/dd/yyyy" renderAsPopup="true>
    <ace:ajax event="dateSelect" listener="#{mainReport.dateSelected}"/>
    </ace:dateTimeEntry>
    </f:facet>
    <h:outputText value="#{row.scanDate}" />
    </ace:column>
    
  3. So, after you do this, you should have corresponding bean values, and corresponding getters and setters. now in the Bean: your listener looks like this:

    public void dateSelected(DateSelectEvent e) throws ParseException {
    
           setScanDateFilter(dateFormatForFilter(e.getDate()));
    }
    

Ok, here, dateFormatForFilter(Date d), is a method that converts Date to String in customized formats. and the reason being, the filterValue which you see on the column accepts only String formats and the value of the ace data entry is Date format. So basically, whatever is selected in that date box will be set to the filterValue and hence it will be filtered by the selected value.

If you dont want that filter box which automatically gets displayed, below the dataEntry box, add an attribute for the above column as: filterStyle="display:none", and that will take care of it. So now you can see something like this:

I could have attached the resulting screenshot , but stackoverflow doesn't let me do that.So, lemme know if this makes sense.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top