This Question is Answered

1 "correct" answer available (4 pts) 1 "helpful" answer available (2 pts)
7 Replies Last post: Nov 1, 2006 3:46 PM by Tatyana Matveyeva  
Bitrose   18 posts since
Oct 30, 2006
Currently Being Moderated

Oct 31, 2006 2:37 PM

Defining my own Filter-Field

Hello

 

I'd like to have a Filter-Combobox for my DataTable row which has numbers as data. Is it possible to have combobox-entries like:

in my "String-row" ?

 

Thanks for help

-- Bitrose

Tatyana Matveyeva   873 posts since
Aug 16, 2006
Currently Being Moderated
1. Oct 31, 2006 4:25 PM in response to: Bitrose
Re: Defining my own Filter-Field

Hello,

 

Yes, you can specify a function that will return the number ranges. Here is an example with part of JSP page:

 

<q:dataTable var="person" 
               value="#{PeopleList.person}"
               rowKey="#{person.id}">
    <q:column filterExpression="#{person.name}"
              filterKind="searchField">
      <f:facet name="header">
        <h:outputText value="Name" ></h:outputText>
      </f:facet>
      <h:outputText value="#{person.name}" ></h:outputText>
    </q:column>
    <q:column filterExpression="#{PeopleList.personAgeRange}" filterKind="comboBox">
      <f:facet name="header">
        <h:outputText value="Age"></h:outputText>
      </f:facet>
      <h:outputText value="#{person.age}" ></h:outputText>
    </q:column>
  </q:dataTable>

 

And getPersonAgeRange() method from “PeopleList” backing bean:

 

public String getPersonAgeRange() {

    Person person = (Person) FacesUtil.getRequestMapValue("person");
    int age = person.getAge();
    if (age <= 10)
      return "0-10";
    if (age <= 20)
      return "11-20";
    if (age <= 30)
      return "21-30";
    if (age <= 40)
      return "31-40";
    return ">40";
  }

Currently, you cannot directly delete entries from the filter field. If there is at least one empty cell in the column, these entries will be added automatically. You can only change text for these entries. We will consider providing an option to hide these entries.

 

Regards,

Tatyana

Tatyana Matveyeva   873 posts since
Aug 16, 2006
Currently Being Moderated
3. Oct 31, 2006 5:17 PM in response to: Bitrose
Re: Defining my own Filter-Field

You cannot explicitly change the width of a filter field. Its width is equal to the column width. You can change the column width with the “style” attribute of the <q:column> tag.

 

Regards,

Tatyana

Tatyana Matveyeva   873 posts since
Aug 16, 2006
Currently Being Moderated
4. Oct 31, 2006 5:58 PM in response to: Bitrose
Re: Defining my own Filter-Field

You can use filterValues attribute to retrieve list of filter values in order you need. Here is an example:

 

..
<q:column filterExpression="#{PeopleList.personAgeRange}"      filterKind="comboBox"
                 filterValues="#{PeopleList.ageRanges}">
      <f:facet name="header">
        <h:outputText value="Age"></h:outputText>
      </f:facet>
      <h:outputText value="#{person.age}" ></h:outputText>
 </q:column>
..

 

And method from “PeopleList” backing bean:

 

  public List getAgeRanges(){
    myAgeRanges.add(">40");
    myAgeRanges.add("31-40");
    myAgeRanges.add("21-30");
    myAgeRanges.add("11-20");
    myAgeRanges.add("0-10");

    return myAgeRanges;
  }

 

Tatyana Matveyeva   873 posts since
Aug 16, 2006
Currently Being Moderated
6. Nov 1, 2006 12:46 PM in response to: Bitrose
Re: Defining my own Filter-Field

Hello,

 

Yes, you are right. It was my mistake, in the current version of the QuipuKit library there is no possibility to change the order of entries in the filter field. But we will provide it in one of our next minor updates of QuipuKit.

 

Regards,

Tatyana

Tatyana Matveyeva   873 posts since
Aug 16, 2006
Currently Being Moderated
7. Nov 1, 2006 3:46 PM in response to: Tatyana Matveyeva
Re: Defining my own Filter-Field

This feature will be available in the QuipuKit library version 1.0.1.

 

Regards,

Tatyana

More Like This

  • Retrieving data ...