function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
KRayKRay 

Sub-Header in DataTable

Hey Guys, I'm having trouble creating a table with a sub header. I'd like to use standard visualforce components but I'm not sure its possible. Here's a sample image. Currently, I'm using a dataTable with a column header of "Main Header". I having trouble creating the "Sub Headers". I've tried to nest dataTables but I dont want to subHeader to repeat. Any and All feedback is welcome. Thanks
Example Table and Header
Best Answer chosen by KRay
Prabhat Kumar12Prabhat Kumar12
Hi KRay i don't find any standard functionality to do this, there is workaround and you can achieve this by defining table in your header of the data table. Please look into following code and let me know if does not work.
 
<apex:page controller="dataTableCon" id="thePage">

    <apex:dataTable value="{!accounts}" var="account" id="theTable" rowClasses="odd,even"

                        styleClass="tableClass">
                        
        <apex:facet name="header">
                
       <table style="text-align:center;" border="1" width="100%">
        <tr>
            <td  colspan="3">Main Header</td>
        </tr>
        <tr>
            <td>Sub Headdr #1</td>
            <td>Sub Headdr #2</td>
            <td>Sub Headdr #3</td>
        </tr>
    </table>                 
                        
</apex:facet>
       

        <apex:column >

              

            <apex:outputText value="{!account.name}"/>

        </apex:column>

        <apex:column >

           
            <apex:outputText value="{!account.owner.name}"/>

        </apex:column>
        
        
        <apex:column >

           
            <apex:outputText value="{!account.billingCity}"/>

        </apex:column>


    </apex:dataTable>

</apex:page>