Luca Molteni
Luca Molteni

Reputation: 5370

Is there a JSF multi column dataTable?

I need to render a JSF Data Table in a different way: since I have a mid size list of a single column entity, I would like to split it in n different column based on a parameter.

Example: instead of

Value1 
Value2 
Value3
Value4 
Value5

I would like to have

Value1 Value3 Value5
Value2 Value4

Is there such a component? In the meanwhile I'll start code it :)

Currently I'm using richfaces.

Upvotes: 2

Views: 1372

Answers (1)

BalusC
BalusC

Reputation: 1108792

Use <rich:dataGrid> instead of <rich:dataTable> (or <h:dataTable>).

<rich:dataGrid value="#{bean.items}" var="item" columns="#{bean.columns}">
    <h:outputText value="#{item}" />
</rich:dataGrid>

If #{bean.columns} returns 3, then it'll render a 3-column data grid.

Upvotes: 4

Related Questions