+ Start a Discussion
RajashriRajashri 

VisualForce Page-Display Column in single row

Hi,

I have created the visualforce page and i am using two different variables using PageBlock table.
Page Block tabl creates two different sections.

How can i show all the columns in single row.below is my VF page 

<apex:page controller="callCampaignController">
    <apex:form >
        <apex:pageBlock title="Campaign Members Details" >
                       <apex:pageblocktable value="{! CampaignMembers}"  var="cm">
                        <apex:column >
                        <apex:pageblocktable value="{!cm.ActivityHistories}" var="tm">
                        <apex:column headerValue="Subject">
                               <apex:outputfield value="{!tm.Subject}"/>
                         </apex:column>
                         </apex:pageblocktable>
                               
                       <apex:pageblocktable value="{!cm.CampaignMembers}" var="cpm">
                      
                        <apex:column headerValue="Member Status">
                               <apex:outputfield value="{!cpm.Status}"/>
                                </apex:column>
                                                                  
                                </apex:pageblocktable>
            </apex:column>
            </apex:pageblocktable>
       
        </apex:pageBlock>
    </apex:form>
</apex:page>
Best Answer chosen by Rajashri
Deepak Kumar ShyoranDeepak Kumar Shyoran
Use this code and it will show you both of your column in  a single row.

<apex:page controller="callCampaignController">
<apex:form >
        <apex:pageBlock title="Campaign Members Details" >
                       
                <apex:pageblocktable value="{! CampaignMembers}"  var="cm">
                           <apex:column >
                               <apex:pageblocktable value="{!cm.ActivityHistories}" var="tm">
                                   <apex:column headerValue="Subject">
                                       <apex:outputfield value="{!tm.Subject}"/>
                                   </apex:column>
                               </apex:pageblocktable>
                           </apex:column >
                           <apex:column >
                               <apex:pageblocktable value="{!cm.CampaignMembers}" var="cpm">                      
                                   <apex:column headerValue="Member Status">
                                       <apex:outputfield value="{!cpm.Status}"/>
                                    </apex:column>                                                                 
                               </apex:pageblocktable>
                        </apex:column>
            </apex:pageblocktable>
           
        </apex:pageBlock>
    </apex:form>
</apex:page>

All Answers

SarfarajSarfaraj
Hi Rajashri

Can you please provide the code for corresponding controller?

--Akram
Deepak Kumar ShyoranDeepak Kumar Shyoran
You can use <apex:repeat> tag in please of <apex:pageBlockTable > to display your column in single row.

Use below code.
<apex:page controller="callCampaignController">
    <apex:form >
        <apex:pageBlock title="Campaign Members Details" >
			<apex:pageblocktable value="{! CampaignMembers}"  var="cm">
					<apex:column >
							<apex:repeat value="{!cm.ActivityHistories}" var="tm">
								<apex:column headerValue="Subject">
									<apex:outputfield value="{!tm.Subject}"/>
								</apex:column>
							</apex:repeat>
                               
							<apex:repeat value="{!cm.CampaignMembers}" var="cpm">
								<apex:column headerValue="Member Status">
									<apex:outputfield value="{!cpm.Status}"/>
								</apex:column>
							</apex:repeat>
					</apex:column>
            </apex:pageblocktable>
        </apex:pageBlock>
    </apex:form>
</apex:page>
May be it will solve your problem

RajashriRajashri
Hi Deepak,

I tried your code.
I am getting the below error

<apex:column> must be the direct child of either <apex:dataTable> or <apex:pageBlockTable>

Any idea? How to resolve it?


RajashriRajashri
Hi Akram,

Below is my controller code.

I want to show all the fileds in single row.Currently it's creating different pageblocks.
RajashriRajashri
Controller code 

public with sharing class callCampaignController {
       
      private List<Schema.Campaign> CampaignMembers;
    public List<Schema.Campaign> getCampaignMembers() {
               
          CampaignMembers=[Select ID,Name, (Select Campaign.Name,Contact.Phone,Lead.FirstName,Lead.LastName,LeadID,Lead.Phone,Lead.Email, Lastmodifieddate,Status,CampaignId From CampaignMembers),
(Select Subject, Id,lastModifiedDate From ActivityHistories order by LastModifiedDate desc LIMIT 1 )
From Campaign order by LastModifiedDate desc];


       return CampaignMembers;
  
           }
  

}
Deepak Kumar ShyoranDeepak Kumar Shyoran
Use this code and it will show you both of your column in  a single row.

<apex:page controller="callCampaignController">
<apex:form >
        <apex:pageBlock title="Campaign Members Details" >
                       
                <apex:pageblocktable value="{! CampaignMembers}"  var="cm">
                           <apex:column >
                               <apex:pageblocktable value="{!cm.ActivityHistories}" var="tm">
                                   <apex:column headerValue="Subject">
                                       <apex:outputfield value="{!tm.Subject}"/>
                                   </apex:column>
                               </apex:pageblocktable>
                           </apex:column >
                           <apex:column >
                               <apex:pageblocktable value="{!cm.CampaignMembers}" var="cpm">                      
                                   <apex:column headerValue="Member Status">
                                       <apex:outputfield value="{!cpm.Status}"/>
                                    </apex:column>                                                                 
                               </apex:pageblocktable>
                        </apex:column>
            </apex:pageblocktable>
           
        </apex:pageBlock>
    </apex:form>
</apex:page>

This was selected as the best answer