7 Replies Latest reply on Jan 26, 2011 1:55 PM by nimoh

    ExtendedDataTable not working nice with filterMethod

    granite2009

      I want to change filtering from startWith to contain in extendedDataTable. I got the logic to work but the layout is broken. First the input box is on the first row instead of the second row. Second, sort cannot work at the same time since once I click on the input box, it triggers a sort immediately. Is there anything I should doing to filterMethod works nice with extendedDataTable?

      I am using SEAM 2.2, richfaces 3.x, jBoss 5.1 . These code are mostly generated by jBoss tools 3.1 on Eclipse 3.5

       

      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
          xmlns:s="http://jboss.com/products/seam/taglib"
          xmlns:ui="http://java.sun.com/jsf/facelets"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:a4j="http://richfaces.org/a4j"
          xmlns:rich="http://richfaces.org/rich" template="layout/template.xhtml">

       

          <ui:define name="body">
              <h:form>

               <rich:extendedDataTable id="table" var="form" reRender="datascroller"
                      value="#{formList.resultList}" rows="10" sortMode="single">
                      <rich:column sortable="true" sortBy="#{form.id}" label="ID"
                          filterBy="#{form.id}" filterEvent="onkeyup" width="50px">
                          <f:facet name="header">Id</f:facet>
                          #{form.id}
                          </rich:column>
                      <rich:column filterMethod="#{formList.filterTitle}" label="Title" width="100px">
                          <f:facet name="header"><h:outputText value="Title"/></f:facet>
                          <f:facet name="header2">
                          <h:inputText value="#{formList.filterValue}">
                          <a4j:support ajaxSingle="true" requestDelay="500" event="onchange" reRender="table,datascroller"></a4j:support>
                          </h:inputText>
                          </f:facet>
                          <s:link id="form" value="#{form.title}" view="/form.xhtml">
                              <f:param name="formId" value="#{form.id}" />
                          </s:link>
                          <rich:toolTip>Edit</rich:toolTip>
                      </rich:column>

                   <f:facet name="footer">
                          <rich:datascroller id="datascroller" renderIfSinglePage="false"/>
                      </f:facet>
                  </rich:extendedDataTable>

      </ui:define>

       

      </ui:composition>


      @Name("formList")
      public class FormList extends EntityQuery<Form>
      {
          /**
           *
           */
          private static final long serialVersionUID = 1L;
          private String filterValue="";

       

          public FormList()
          {
              setEjbql("select Form from Form Form");
          }
         
          public boolean filterTitle(Object parmForm) {
              if (getFilterValue().length()==0) {
                  return true;
              }
              Form form = (Form)parmForm;
              String title=form.getTitle().toLowerCase();
              int i=title.indexOf(this.filterValue.toLowerCase());
              if (i>=0) {
                  return true;
              } else {
                  return false;
              }
          }

       

          public void setFilterValue(String filterValue) {
              this.filterValue = filterValue;
          }

       

          public String getFilterValue() {
              return filterValue;
          }

       

      }

        • 1. Re: ExtendedDataTable not working nice with filterMethod
          ilya_shaikovsky

          the component is community contributed and was not changed much by the team. We will revise it in 4.x but currently seems you could only turn of default sorting with selfSorted and define with your own controls. Additional not used header row could be hidden via css.

          • 2. Re: ExtendedDataTable not working nice with filterMethod
            m.a.g

            Hm, what does "header2" mean? Documentation says nothing about facet named "header2".

            • 3. Re: ExtendedDataTable not working nice with filterMethod
              granite2009

              header2 does not mean anything. I just try my luck to make the filter row go to the second row, which it failed.

               

              Is it difficult to change the component to compare by contain instead of startwith? I looked and does not seems to be easy. Any help? Especailly from the community who donated this component.

              • 4. Re: ExtendedDataTable not working nice with filterMethod
                sushant380

                hey guys,
                         I guess i found the solution on this. Now i can use both custome filtering and sorting together in rich extended data table. I went through the example from live demo of custome filtering. I did slight modification in code and done. Instead of putting textbox in rich:column header facet, i have put that in facet of rich:columnGroup. Below is my code for custome filtering and sorting. Dont forget to put blank <h:outputText/> in rich:column facet header, otherwise it will disable sorting option as rich column is searching for clickble component.
                    
                     <rich:extendedDataTable width="800px" id="cdrlist"
                                    rows="100"
                                    value="#{displayList}"
                                    var="dto"
                                    rendered="#{not empty displayList}"
                                    title="Car Details" height="582">
                                <f:facet name="header">
                                    <rich:columnGroup>
                                            <rich:column>
                                                <h:outputText value="Cars" />
                                            </rich:column>
                                            <rich:column>
                                                <h:panelGroup>
                                                    <h:outputText value="Cars" />
                                                    <h:inputText
                                                        value="#{tableFilter.cars}" style="width:100%">
                                                        <a4j:support event="onblur"
                                                            reRender="cdrlist"
                                                            ignoreDupResponses="true" />
                                                    </h:inputText>
                                                </h:panelGroup>

                 

                                            </rich:column>
                                            <rich:column>
                                                <h:panelGroup>
                                                    <h:outputText value="Models" />
                                                    <h:inputText
                                                        value="#{tableFilter.models}" style="width:100%">
                                                        <a4j:support event="onblur"
                                                            reRender="cdrlist"
                                                            ignoreDupResponses="true" />
                                                    </h:inputText>
                                                </h:panelGroup>
                                            </rich:column>
                                        </rich:columnGroup>
                                    </f:facet>
                                    <rich:column label="Cars" align="center"
                                        width="100px" sortBy="#{dto.cars}" filterMethod="#{tableFilter.filterCars}">
                                        <f:facet name="header">
                                            <h:outputText/>
                                        </f:facet>
                                        <h:outputText value="#{dto.cars}" />
                                    </rich:column>
                                    <rich:column label="Models" align="center"
                                        width="100px" sortBy="#{dto.models}"  filterMethod="#{tableFilter.filterModels}">
                                        <f:facet name="header">
                                            <h:outputText/>
                                        </f:facet>
                                        <h:outputText value="#{dto.models}" />
                                    </rich:column>
                                   
                                </rich:extendedDataTable>

                 

                i hope it will help you to solve your problem. Remember the blank <h:outputText/> tag in header facet of below <rich:column> tag for sorting buttons

                 

                Regards
                sushant

                • 5. Re: ExtendedDataTable not working nice with filterMethod
                  ilya_shaikovsky

                  in order to replace standard filtering input with custom - could use filterValueInput facet. IT was not documented but works well for me.

                  • 6. Re: ExtendedDataTable not working nice with filterMethod
                    sushant380

                    IIlya, I tried that but its not working with richfaces 3.3.3. Where to place that? inside rich:column..right?..can you show me code snippet which worked for u?

                    • 7. Re: ExtendedDataTable not working nice with filterMethod
                      nimoh

                      I believe the facet should be filter and not filterValueInput.

                       

                      e.g.

                       

                      <f:facet name="filter">