Reputation: 7116
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
Upvotes: 3
Views: 9871
Reputation: 108969
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>
Upvotes: 1
Reputation: 81667
Maybe you can have a look to advanced components libraries, such as RichFaces that offer more complex structures for datatables, like in this example.
Upvotes: 0
Reputation: 13855
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.
Upvotes: 0