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

How to match PageBlock width with DataTable width

I have a VF page for a custom object and when viewed, the PageBlock  is not as wide as the DataTable.  The DataTable looks fine but the rightmost 6 DataTable columns (out of 17) extend beyond the right border of the PageBlock.  How can I get the PageBlock to be as wide as the DataTable? 


<apex:page Controller="Rpt_AG_Opp_Pipeline_Controller" showheader="false" title="Agency Group Report">

<apex:form >

   <apex:sectionHeader title="Opportunity Pipeline" />

   <apex:pageBlock title= "Agency Group: {!AgencyGroupName}" >

   <apex:pageblockbuttons >

       <apex:commandButton action="/apex/Rpt_AG_Opp_Pipeline_xls?id={!AgencyGroupId}" value="Excel"/>


   <apex:datatable value="{!OppWrapList}" var="OppList" >

       <apex:column headerValue="Prod Office" style="text-align:center" value="{!OppList.Prod_Office}" />

        ...... (more columns)






PageBlock tries to be as wide as allowed by space remaining after sidebar, such that it tries not to go off the page. You should make your dataTable smaller, as it's fairly non-trivial to override salesforce's CSS (and will probably break later if you try).