4 Replies Latest reply on Feb 8, 2013 3:08 AM by Christophe Noel

    Dynamic DataTable are not Sortable

    Christophe Noel Newbie

      Hi,

       

      I'm using Richfaces 4.3.0RC1

      The only solution to create a dynamic datatable (with a variable number of columns, as with <rich:columns> in RF 3.3.3) consists in using JSTL <c:forEach>.

      (columns no more exist,  ui:repeat no yet works for tables)

       

      In that case, sorting is not working (both with dataTable and extendedDatatable built-in OR usual sorting method).

       

      Just for illustrating, I'm copying my code here below.

       

      Is there an alternative ? When is planned the columns or repeat support ?

       

      Thanks a lot

       

      <rich:extendedDataTable id="dataTable#{popId}"
                                                                            styleClass="fullWidthTable" var="record" selectionMode="none"
                                                                            value="#{viewer.getDataOperation.response.records}"
                                                                            rendered="#{(viewer.views[viewer.selectedView].type eq 'TABLE')}"
                                                                            rows="8">
                                                                            <c:forEach items="#{viewer.getDataOperation.response.fields}"
                                                                                      var="fieldName">
                                                                                      <rich:column sortBy="#{record[response.getId(fieldName)]}">
                                                                                                <f:facet name="header">
                                                                                                          <h:outputText value="#{fieldName}" />
                                                                                                </f:facet>
                                                                                                <h:outputText value="#{record[response.getId(fieldName)]}" />
                                                                                      </rich:column>
                                                                            </c:forEach>
                                                                  </rich:extendedDataTable>
      
      
        • 1. Re: Dynamic DataTable are not Sortable
          Suresh G Newbie

          you have created datatable data in setter & getter methods. Get the dataTable outside of setter & getter methods

          like

          in .xhtml

           

          <rich:extendedDataTable id="#{dataTable.popId}" var=record>

               <rich:column sortBy="#{ record.Id}">

               <f:facet name="header">
                <h:outputText value="Id" />
                 </f:facet>
                <h:outputText value="#{record.Id}" />

               </rich:column>

          </rich:extendedDataTable>

           

          In Bean

          public List<popIddata> popId= new ArrayList<popIdtdata>();

           

          public List<PopIddata> getPopId() {

                  return popId;

              }

           

           

              public void setPopId(List<PopIddata> popId) {

                  this.popId = popId;

              }

           

          public String gettingData(){

          popId.add(new popIddata("","","",))

          }

           

           

          Call gettingData() where ever data you need.



          • 2. Re: Dynamic DataTable are not Sortable
            Christophe Noel Newbie

            Hi Suresh,

             

            This could be the problem, but records is populated outside the getters / setters.

             

             

            public List<ArrayList<String>> getRecords() {
                                return records;
                      }
            
            
                      public void setRecords(List<ArrayList<String>> records) {
                                this.records = records;
                      }
            
            public DataResponse(
                                          GetDataResponseMessageDocument getDataResponseMessageDocument)
                                          throws Exception {
                                setXmlResponse(getDataResponseMessageDocument);
                                this.parse(); // here !!
                      }
            
            

             

            Thanks a lot for your help.

            • 3. Re: Dynamic DataTable are not Sortable
              Suresh G Newbie

              Please Remove c:froEach Tag and then try.

              Still if you are facing same problem, share your code again .xhtml files

              • 4. Re: Dynamic DataTable are not Sortable
                Christophe Noel Newbie

                As I said in my initial post, "c:forEach" causes the problem. But this is currently the only way to create dynamic tables.

                Regards.