views:

1838

answers:

3

Hey guys, is there a way using JSF to group two or more columns under a single parent column in JSF? I have a dataTableEx with hx:columnEx columns inside of it. What I want is something like this:

 [MAIN HEADER FOR COL1+2   ][Header for Col 3+4]

 [ COL1 Header][COL2 Header][COL3    ][COL 4   ] 

 Data          Data             Data     Data

 Data          Data             Data     Data

 Data          Data             Data     Data

 Data          Data             Data     Data

Data Data Data Data

Thanks

A: 

Your best bet is likely to use nested tables for the first header (first header in the outer table, and your second header and data inside a nested table) so that it looks like two headers.

Elie
Nesting JSF dataTables is a bad idea.
McDowell
the outer table wouldn't be a JSF Data Table, just the inner one. The outer one would just display the column headings you want.
Elie
A: 

Maybe you can have a look to advanced components libraries, such as RichFaces that offer more complex structures for datatables, like in this example.

romaintaz
A: 

You can probably achieve what you want with the table header, a panelGrid and a little CSS.

<style type="text/css">
.colstyle {
 width: 25%
}
</style>
</head>
<body>

<f:view>
 <h:dataTable border="1" value="#{columnsBean.rows}" var="row"
  columnClasses="colstyle">
  <f:facet name="header">
   <h:panelGrid columns="2" border="1" style="width: 100%">
    <h:outputLabel style="width: 100%" value="MAIN HEADER FOR COL1+2" />
    <h:outputLabel style="width: 100%" value="MAIN HEADER FOR COL3+4" />
   </h:panelGrid>
  </f:facet>
  <h:column>
   <f:facet name="header">
    <h:outputText value="COL1 Header" />
   </f:facet>
   <h:outputLabel value="#{row.col1}" />
  </h:column>
  <h:column>
   <f:facet name="header">
    <h:outputText value="COL2 Header" />
   </f:facet>
   <h:outputLabel value="#{row.col2}" />
  </h:column>
  <h:column>
   <f:facet name="header">
    <h:outputText value="COL3 Header" />
   </f:facet>
   <h:outputLabel value="#{row.col3}" />
  </h:column>
  <h:column>
   <f:facet name="header">
    <h:outputText value="COL4 Header" />
   </f:facet>
   <h:outputLabel value="#{row.col4}" />
  </h:column>
 </h:dataTable>
</f:view>
McDowell