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
BrianWKBrianWK 

Datatable and pageblocktable not taking full width of page

I recently created my first visualforce page where I'm listing through a collection of information. I've tried both Datatable and pageblocktable and I'm having the same issue with both. When the page renders it appears that the table takes less than 50% of the actual page. I've tried changing the width on the table, the width of each column, I've tried columnswidth and various combination including setting the number of columns in the table. Each time I get very minimal changes where the total width of the table never exceeds 50% of the page width. This causes the data strings in my columns to wrap and appear "smushed" when you can clearly see plenty of "Blank" space off to the right. Example of one of my many attempts is below. Any suggestions on how I can make my table actually use the full space available and not end up with really narrow columns? The only time I can seem to "stretch" the column is when I only display  1 or 2 columns and not the complete 4.
 
Code:
          <apex:pageblocktable value="{!Issues}" var="each" width="100%">
            <apex:column width="100%" headervalue="Issue"  >{!each.Issue__c}</apex:column> 
            <apex:column width="100%" headervalue="Message Type" > {!each.Type__c}</apex:column>
            <apex:column width="100%" headervalue="Reported Date" ><apex:outputfield value="{!each.Date__c}"/></apex:column>
            <apex:column  width="100%" headervalue="Comments" >{!each.Client_Comments__c}</apex:column>
          </apex:pageblocktable>

 
Best Answer chosen by Admin (Salesforce Developers) 
TehNrdTehNrd
Is your dataTable in a pageBlockSection with 2 columns?

All Answers

TehNrdTehNrd
Is your dataTable in a pageBlockSection with 2 columns?
This was selected as the best answer
jwetzlerjwetzler
That's my guess.  The default number of columns for pageBlockSection is 2, you'll need to set it to 1 to get it to take up the whole width.
BrianWKBrianWK
Ah Hah! That was it! I didn't even think about looking at the pageblocksection - my error. thank you!
JPClarkJPClark
thanks
CharlyGCharlyG

 

<apex:pageblock >
  <apex:pageBlockSection title="1. Entrance & Reception" columns="1">

 If you add the column attribute to your section, and the value is 1, the datatable or pageblocktable will span the whole page.