4 Replies Latest reply on Sep 4, 2009 5:40 PM by nbelaevski

    Boolean filter on datatable

    jfaath

      I'm using a datatable with the filtering mechanism which is working great for text fields.

      However, I have a boolean field that I'd like to filter on. Doing the same thing I do for text fields, it works, except you have to type in the word 'true' for the field to filter on 'true' values.

      Is there any built-in support for boolean fields, say, where there would be a select box? Or, is there any simple way to do this?

      Thanks,

      JF

        • 1. Re: Boolean filter on datatable
          ilya_shaikovsky

          how about something like this:

           <rich:column
           filterExpression="#{cap.checked==filteringBean.filterChecked}">
           <f:facet name="header">
           <h:selectBooleanCheckbox value="#{filteringBean.filterChecked}">
           <a4j:support event="onchange" reRender="table, ds2" />
           </h:selectBooleanCheckbox>
           </f:facet>
          
           <h:selectBooleanCheckbox value="#{cap.checked}" />
           </rich:column>
          


          or filterMethod and select with some options like checked/unchecked/any instead of checkbox could be better in usage.

          • 2. Re: Boolean filter on datatable
            jfaath

            Thanks for your suggestion. Based on that, and the fact that I just noticed there was a whole section on table filtering, I was able to find a solution.

            • 3. Re: Boolean filter on datatable
              jfaath

              Quick question: I've implemented the solution with a select box. However, I also want to use the built-in sorting.

              The problem is, because the select box is in the header, whenever it is changed (or, just clicked) the column is sorted as well.

              Is there any way to combine both without this issue?

              • 4. Re: Boolean filter on datatable
                nbelaevski

                Hi,

                You can prevent this by adding

                onclick="Event.stop(event)"