0

I need to create a table with this structure:

Column A     Column B     Column C     Column D
 xxxx         xxxx         xxxx         xxxx
Column E     Column F     Column G     Column H
 xxxx         xxxx         xxxx         xxxx

This is gonna be repeated N times, according to the amount of items on my list.

I made a Google search and didn't find any example with multiple rows.

I have tried using datatableinside the main datatable but no results.

4
  • is it close ? primefaces.org/showcase/ui/datatableSubTable.jsf Commented May 14, 2012 at 14:33
  • nah...I gave a look at those PrimeFaces examples and nothing is close to what I need but thanks Commented May 14, 2012 at 14:36
  • 1
    take a look at this datatables.net might find some thinig over there , and you can itegrate it with JSF Commented May 14, 2012 at 14:37
  • Thanks for the link, I'm gonna check Commented May 14, 2012 at 14:38

4 Answers 4

1

I would create a HTML table and use EL and if necessary, that works for me.

Sign up to request clarification or add additional context in comments.

Comments

1

How about something like this:

   <h:dataTable value="#{bean.items}" var="item">
        <table>
          <tr>
              <td>column A</td>
              <td>column B</td>
              <td>column C</td>
              <td>column D</td>
          </tr>
          <tr>
              <td>#{item.columnA}</td>
              <td>#{item.columnB}</td>
              <td>#{item.columnC}</td>
              <td>#{item.columnD}</td>
          </tr>
          <tr>
              <td>column E</td>
              <td>column F</td>
              <td>column G</td>
              <td>column H</td>
          </tr>
          <tr>
              <td>#{item.columnE}</td>
              <td>#{item.columnF}</td>
              <td>#{item.columnG}</td>
              <td>#{item.columnH}</td>
          </tr>
        </table>
    </h:dataTable>

Comments

0

The simplest approach using standard JSF components would be to just render the cell values below each other in a single column/cell.

<h:dataTable value="#{bean.items}" var="item">
    <h:column>#{item.columnA}<br/>#{item.columnE}</h:column>
    <h:column>#{item.columnB}<br/>#{item.columnF}</h:column>
    <h:column>#{item.columnC}<br/>#{item.columnG}</h:column>
    <h:column>#{item.columnD}<br/>#{item.columnH}</h:column>
</h:dataTable>

You could if necessary wrap each value in a <div> and throw in some CSS accordingly with the right dimensions, borders and backgrounds to make it look like a real row.

Comments

0

You can pass a List<Object[]> accord to your needed and get it on value attribute on <h:datatable> answer here.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.