Grouping columns under one heading in JSF

Hi guys, is there a way to use JSF to group two or more columns under the same parent column in JSF? I have a dataTableEx with hx: columnEx columns inside it. I want 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

thank

+3
source share
3 answers

Perhaps you can achieve what you want with a table title, a grid pane, 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>
0
source

It’s best to use nested tables for the first heading (the first heading in the outer table and your second heading and data inside the nested table) so that it looks like two headings.

0
source

, , RichFaces, , , .

0

Source: https://habr.com/ru/post/1699071/


All Articles