4 Replies Latest reply on Oct 18, 2011 2:16 AM by omid pourhadi

    Add Dynamic Row

    omid pourhadi Newbie

      Hi.

       

      I want to add dynamic rows in Rich:dataTable how can i do that ?

        • 1. Re: Add Dynamic Row
          Christian Peter Expert

          Just add another entry to your List and reRender the table?

          • 2. Re: Add Dynamic Row
            omid pourhadi Newbie

            i think, i didn't explain my problem well enough

             

            i have a datatable and a button as below

             

            <input type="button" onclick="addRowToDataTable()"  value="Add Row"/>

            <rich:dataTable value="" var="_contact" id="dt">

            <rich:column>

             

            </rich:column>

            </rich:dataTable>

             

            i want to everytime a user clicks on button, a row will be added to table dynamically as well as i want to get all rows entry at server

             

            i have no idea how can i implement this in richfaces

            • 3. Re: Add Dynamic Row
              Christian Peter Expert

              Hi,

               

              your button has to call an action in your backing bean to add a new row to your datamodel:

               

              <a4j:commandButton value="add Row" action="#{myDataModelBean.add}" reRender="myTable"/>

               

              <rich:dataTable value="#{myDataModelBean.dataList}" var="r" id="myTable">

              <rich:column>

              #{r}

              </rich:column>

              </rich:dataTable>

               

              your "onclick=..." is just javascript code.

               

               

              Or do you want to add rows on client side and synchronize later with the backingbean?

              • 4. Re: Add Dynamic Row
                omid pourhadi Newbie

                Thanx for your reply,

                 

                Actually I'm writing a richfaces component via CDK and it's combination of these two feature (dataTable and commandButton), so that would be better if it was client side

                 

                is it possible to add rows on client side and synchronize later with the backingbean?