4 Replies Latest reply on Feb 23, 2012 2:02 PM by sunkaram

    Help needed with nested datatable / filter

    semora

      Hi,

       

      i'm brand new to using richfaces and i have a question on nested tables,

       

      i've implemented the nested table and added a filter to it, it works fine however, when the 2nd table is filtered and the list that feeds it becomes empty because of the filter criteria, i would like to not show that row.

       

      example code :

       

      <h:form>
         <rich:dataTable id="listState1" value="#{statesBean.listState}"
          var="varlistState" style="width: 100%;border-width: 0px"  >
          <f:facet name="header">
           <rich:columnGroup>
           
            <rich:column  >
             <h:outputText value="Project Filter : " />
                   <h:inputText value="#{statesBean.projectFilter}">
              <a4j:ajax event="blur" render="listState1" execute="@this" />
             </h:inputText>

            </rich:column>
           
           </rich:columnGroup>
          </f:facet>
          <rich:column id="node1column" style="border-width: 0px" >

          
           <rich:dataTable id="statesList1" value="#{varlistState.statesList}"   

          var="varstatesList" style="width: 100%" rowClasses="odd-row, even-row">
            <f:facet name="header">
           <rich:columnGroup>
            <rich:column rowspan="2" style="width: 150px">
            <h:outputText value="#{varlistState.node}" style="font-size: 14pt;"/>

            </rich:column>
            <rich:column colspan="2" style="width: 125px">
             <h:outputText value="Application Versions" />
            </rich:column>
            <rich:column colspan="2" style="width: 125px">
             <h:outputText value="Properties Versions" />
            </rich:column>
            <rich:column rowspan="2">
             <h:outputText value="State" />
            </rich:column>
             <rich:column rowspan="2">
             <h:outputText value="History" />
            </rich:column>
            <rich:column breakRowBefore="true" style="width: 50px">
             <h:outputText value="Previous" />
            </rich:column>
            <rich:column style="width: 50px">
             <h:outputText value="Current" />
            </rich:column>
            <rich:column style="width: 50px">
             <h:outputText value="Previous" />
            </rich:column>
            <rich:column style="width: 50px">
             <h:outputText value="Current" />
            </rich:column>
           </rich:columnGroup>
          </f:facet>
             <rich:column id="name1column" filterValue="#{statesBean.projectFilter}" filterExpression="#{fn:containsIgnoreCase(varstatesList.name, statesBean.projectFilter)}">
                
                   <h:outputText styleClass="outputText" id="name1"
              value="#{varstatesList.name}">
             </h:outputText>
            </rich:column>
            <rich:column id="prevVersion1column">
            
             <h:outputText styleClass="outputText" id="prevVersion1"
              value="#{varstatesList.prevVersion}">
             </h:outputText>
            </rich:column>
            <rich:column id="currVersion1column">
            
             <h:outputText styleClass="outputText" id="currVersion1"
              value="#{varstatesList.currVersion}">
             </h:outputText>
            </rich:column>
            <rich:column id="prevVersionProps1column">
            
             <h:outputText styleClass="outputText" id="prevVersionProps1"
              value="#{varstatesList.prevVersionProps}">
             </h:outputText>
            </rich:column>
            <rich:column id="currVersionProps1column">
            
             <h:outputText styleClass="outputText" id="currVersionProps1"
              value="#{varstatesList.currVersionProps}">
             </h:outputText>
            </rich:column>
            <rich:column id="currState1column">
            
             <h:selectOneMenu styleClass="selectOneMenu" id="currState1"
              value="#{varstatesList.currState}">
              <f:selectItem itemLabel="Redeployable" itemValue="Redeployable" />
              <f:selectItem itemLabel="#{statesBean.envName}"
                value="#{statesBean.envName}"/>
             </h:selectOneMenu>
            </rich:column>
            <rich:column id="projId1column">
            
             <h:outputText styleClass="outputText" id="projId1"
              value="#{varstatesList.projId}">
             </h:outputText>
            </rich:column>
           </rich:dataTable>
          </rich:column>
         </rich:dataTable>


        </h:form>

        • 1. Re: Help needed with nested datatable / filter
          semora

          oh well. hit ctrl-s and it submitted the form.. here is the rest :

           

          nestedtable.png

          so this is the rendered table.. i would like the Header section with "ret" header column group not to show when the filtered result is empty.. (either hide/skip that iteration of the nested datatable or hide/skip the column of the parent datatable that contains the nested datatable.. i tried to add the

          rendered

          rendered = "#{not empty varlistState.statesList}"

           

          to the datatable and column with no result.. i guess the list is not empty... just that at runtime it skips the lines that return true from the EL function..

           

          anyways, if anyone can help me out would be appreciated.

          regards

           

          • 2. Re: Help needed with nested datatable / filter
            sunkaram

            Not sure if there is a direct way to do this.

            But, as a last option you can try adding a method in bean to return a boolean based on filtered result list, so that you can hide/dispay the header..

            • 3. Re: Help needed with nested datatable / filter
              semora

              Is there a dynamic object for the filtered result list?

               

              because i guess the rendered="#{not empty..." is not working since my variable is not empty..

               

              so if there is a transient object used while filter is on.. i could use that one to compare if empty or not..

               

              anyways.. thanks for the reply.. will look into that possiblity..

              • 4. Re: Help needed with nested datatable / filter
                sunkaram

                Is there a dynamic object for the filtered result list?

                 

                No, I think. You have to create your own method based on filter string and see if there are any results..