5 Replies Latest reply on Sep 7, 2009 12:25 PM by Jay Balunas

    How to use data table to show a dynamic number of rows withi

    Adrian Van't Wout Newbie

      Hi,

      I am trying to figure out how to achieve the following table layout using rich faces data table tags:

      -----------------------------------------------------------------------------
      | Name | Phone | Street Address | State | Actions |
      -----------------------------------------------------------------------------
      | Adrian | 383838 | 34 Blah St | VIC | |
      | | | 22 Hah Rd | NSW | |
      |---------------------------------------------------------------------------|
      | John | 383838 | 345 Blah St | VIC | <modify |
      | | | 21 Hah Rd | NSW | |
      -----------------------------------------------------------------------------

      The data model in the back end is essentially:

      -----------
      | Person |
      -----------
      |
      | *
      -------------
      | Address |
      -------------

      Essentially, each main row is a person record, and within each main row there are sub-rows that show the different addresses. I noticed that there is a rowspan attribute against a column, but since the row span would be fixed for all records, it doesn't seem to support a dynamic number of address rows per person.
      Does anyone have any ideas on how I could use the rich faces table components to achieve this?

      Thanks for your help,

      Adrian

        • 1. Re: How to use data table to show a dynamic number of rows w
          Nick Belaevski Master

          Hi Adrian,

          You can use rich:subtable - check livedemo for more info.

          • 2. Re: How to use data table to show a dynamic number of rows w
            Adrian Van't Wout Newbie

            Hi,

            I have been looking at the livedemo for an example of a subtable - however the usage of a subtable in that example is to have a parent row and then several child rows.
            Maybe my example wasn't clear due to the way the html ended up displaying. This is what I was after. If there is something on the livedemo that I haven't found that gives an example of this, could you please provide the URL?

            Thanks for your help
            Adrian


            ----------------------------------------------------------------------------
            | Name | Phone | Street Address | State | Actions |
            ----------------------------------------------------------------------------
            | Adrian | 383838 | 34 Blah St | VIC | <modify button> |
            | | --------------------------| |
            | | | 22 Hah Rd | NSW | |
            |--------------------------------------------------------------------------|
            | John | 383838 | 345 Blah St | VIC | <modify button> |
            | | |-------------------------| |
            | | | 21 Hah Rd | NSW | |
            -----------------------------------------------------------------------------

            • 3. Re: How to use data table to show a dynamic number of rows w
              Adrian Van't Wout Newbie

              Hi,

              Just wondering if anyone knows how to achieve the below using the richfaces table/subtable?

              Thanks
              Adrian

              "vantwout" wrote:
              Hi,

              I have been looking at the livedemo for an example of a subtable - however the usage of a subtable in that example is to have a parent row and then several child rows.
              Maybe my example wasn't clear due to the way the html ended up displaying. This is what I was after. If there is something on the livedemo that I haven't found that gives an example of this, could you please provide the URL?

              Thanks for your help
              Adrian

              <pre>
              ----------------------------------------------------------------------------
              | Name | Phone | Street Address | State | Actions |
              ----------------------------------------------------------------------------
              | Adrian | 383838 | 34 Blah St | VIC | <modify button> |
              | | --------------------------| |
              | | | 22 Hah Rd | NSW | |
              |--------------------------------------------------------------------------|
              | John | 383838 | 345 Blah St | VIC | <modify button> |
              | | |-------------------------| |
              | | | 21 Hah Rd | NSW | |
              -----------------------------------------------------------------------------

              </pre>


              • 4. Re: How to use data table to show a dynamic number of rows w
                Nick Belaevski Master

                Adrian,

                Use "rowspan" attribute of rich:column.

                • 5. Re: How to use data table to show a dynamic number of rows w
                  Jay Balunas Master

                  Do you have a hard requirement on having the internals be a table?

                  You could just try a standard panel grid inside of the column definition. Something like below :

                  <rich:column>
                   <h:panelGrid columns="2" ...>
                   <a4j:repeat ...>
                   --- Iterate over your data components for the row here. This will result in 2 columns of what ever data you care to put here.
                   </a4j:repeat>
                   </h:panelGrid>
                  </rich:column>
                  


                  Obviously this is pseudo-code - you'll have to add your own details :-)