1 Reply Latest reply on Dec 1, 2014 8:29 AM by cooper_lyt

    Nested collapsibleSubTable other BUG with RichFaces 4.5.0.Final

    cooper_lyt

      I do have 4 levels of collapsibleSubTable nesting,  but i click top collapsibleSubTableToggler not collapse all sub Table!


      All expanded:

      allExp.png

      click second Level  collapsibleSubTableToggler :

      level 2 col.png

      Only collapse Level 3 but Level 4 not collapsed


      Code:


      bean:


       public List<TopLevel> getTopLevelDatas(){
              List<TopLevel> result = new ArrayList<TopLevel>(2);
              result.add(new TopLevel( "test Top level"));
              return result;
          }
      
      
          public static class TopLevel {
      
      
              private String title;
      
      
              private List<SecondLevel> secondLevels = new ArrayList<SecondLevel>(3);
      
      
              public TopLevel(String title) {
                  this.title =  title;
                  secondLevels.add(new SecondLevel("test second Level"));
              }
      
      
             // geter and seter ..
          }
      
      
          public static class SecondLevel {
              private String title;
      
      
              private List<ThirdLevel> thirdLevels = new ArrayList<ThirdLevel>(3);
      
      
      
      
              public SecondLevel(String title) {
                  this.title = title;
                  thirdLevels.add(new ThirdLevel("test third Level"));
              }
      
      
              // geter and seter ..
          }
      
      
          public static class ThirdLevel{
              private String title;
      
      
              private List<String> fourthLevels = new ArrayList<String>(3);
      
      
              public ThirdLevel(String title) {
                  this.title = title;
                  fourthLevels.add("1");
                  fourthLevels.add("2");
                  fourthLevels.add("3");
              }
      
      
              // geter and seter ..
          }
      

       

      Page:

          <r:dataTable value="#{testKnow.topLevelDatas}" var="_topLevel">
              <r:column>
                  <r:collapsibleSubTableToggler id="aaa" for="sbtb2"/>
                  <h:outputText value="#{_topLevel.title}"/>
              </r:column>
              <r:collapsibleSubTable id="sbtb2" value="#{_topLevel.secondLevels}" var="_sencondLevel">
      
      
                  <r:column>
                      <r:collapsibleSubTableToggler id="bbb" for="sbtb3"/>
                      <h:outputText value="#{_sencondLevel.title}"/>
                  </r:column>
      
      
                  <r:collapsibleSubTable id="sbtb3" value="#{_sencondLevel.thirdLevels}" var="_thirdLevel">
                      <r:column>
                          <r:collapsibleSubTableToggler for="sbtb4"/>
                          <h:outputText value="#{_thirdLevel.title}"/>
                      </r:column>
      
      
                      <r:collapsibleSubTable  id="sbtb4" value="#{_thirdLevel.fourthLevels}" var="_fourthLevel">
                             <r:column>
                                 <h:outputText value="#{_fourthLevel}"/>
                             </r:column>
                      </r:collapsibleSubTable>
      
      
                  </r:collapsibleSubTable>
      
      
              </r:collapsibleSubTable>
          </r:dataTable>
      
        • 1. Re: Nested collapsibleSubTable other BUG with RichFaces 4.5.0.Final
          cooper_lyt

          Solve

           

          in richfaces-4.5.0.Final.jar/resources/org.richfaces/collapsible-subtable.js


                      collapse: function (options) {
          
          
                          //============  collapse sub table ==============
                          if (this.isNested) {
                              var expandedTogglerRegex = new RegExp("^" + this.id + "\\:\\d+\\:\\w+\\:expanded$");
                              var collapseTogglerRegex = new RegExp("^" + this.id + "\\:\\d+\\:\\w+\\:collapsed$");
                              var subtableRegex = new RegExp("^" + this.id + "\\:\\d+\\:\\w+$");
                              $(document.getElementById(this.id)).parent().find("tr[style='display: none;']").filter(function () {
                                  return this.id.match(subtableRegex);
                              }).each(function () {
                                  if (this.rf) {
                                      if (this.rf.component.isExpanded) {
                                          $(document.getElementById(this.id)).parent().find(".rf-csttg-exp").filter(function () {
                                              return this.id.match(expandedTogglerRegex);
                                          }).each(function () {
                                              $(this).hide();
                                          });
                                          $(document.getElementById(this.id)).parent().find(".rf-csttg-colps").filter(function () {
                                              return this.id.match(collapseTogglerRegex);
                                          }).each(function () {
                                              $(this).show();
                                          });
                                          this.rf.component.collapse();
                                      }
                                  }
                              });
                          }
          
          
                          // =======================================
                          this.setState(rf.ui.CollapsibleSubTable.collapse);
                          element.call(this).hide();
                      },
          
          

           

          may i submit a pull request?