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
Supriyo Ghosh 5Supriyo Ghosh 5 

Grid panel in vf page

Hi,

I want to add grid in my vf page and also show as landscape mode.Please help.

My vf page
<apex:page id="p1" standardController="Employee_Master__c" extensions="EmpMasterReport" sidebar="false" 
        renderAs="PDF" showHeader="false">
     <apex:form >
        <apex:pageBlock title="Employee Master Details" id="Emp_Master">
            <apex:pageBlockTable value="{! EmpList }" var="em">
                <apex:column value="{!em.Name}"/>
                
                <apex:column value="{!em.Address__c}"/>
                
                <apex:column value="{!em.Date_Of_Birth__c}"/>
                
                <apex:column value="{!em.Date_Of_Joining__c}"/>
                
                <apex:column value="{!em.Date_of_Leaving__c}"/>
                
                <apex:column value="{!em.Thumbnail__c}"/>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
    
</apex:page>

Apex class

public class EmpMasterReport
{
   public List<Employee_Master__c> EmpList {get;set;}
   
    public EmpMasterReport(ApexPages.StandardController stdController) 
    {
        EmpList = new     List<Employee_Master__c>();
        EmpList = [ SELECT Name,Address__c,Date_Of_Birth__c,Date_Of_Joining__c,Date_of_Leaving__c,Thumbnail__c FROM Employee_Master__c where Active__c=true and Photo__c !=null];
    }
    
    public EmpMasterReport()
    {
        EmpList = new     List<Employee_Master__c>();
        EmpList = [ SELECT Name,Address__c,Date_Of_Birth__c,Date_Of_Joining__c,Date_of_Leaving__c,Thumbnail__c FROM Employee_Master__c where Active__c=true and Photo__c !=null];
    }
   
}

Please help.
Sunil MadanaSunil Madana
Hi, not sure if you got the answer. Otherwise, please use the below Visualforce code which might help you.
<apex:page id="p1" standardController="Employee_Master__c" extensions="Class_906F0000000D96IIAS" sidebar="false" renderAs="PDF" showHeader="false">
    <apex:form >
        <apex:pageBlock title="Employee Master Details" id="Emp_Master">
            <apex:dataTable value="{!EmpList}" var="em" id="theTable" rowClasses="odd,even" styleClass="tableClass" border="1" width="100%">
                <apex:column>
                    <apex:facet name="header">Name</apex:facet>
                    <apex:outputText value="{!em.name}"/>
                </apex:column>
                <apex:column>
                    <apex:facet name="header">Address</apex:facet>
                    <apex:outputText value="{!em.Address__c}"/>
                </apex:column>
                <apex:column>
                    <apex:facet name="header">Date of Birth</apex:facet>
                    <apex:outputText value="{0, date, MMM '-' d '-' yyyy}">
                        <apex:param value="{!em.Date_Of_Birth__c}"/>
                    </apex:outputText>
                </apex:column>
                <apex:column>
                    <apex:facet name="header">Date of Joining</apex:facet>
                    <apex:outputText value="{0, date, MMM '-' d '-' yyyy}">
                        <apex:param value="{!em.Date_Of_Joining__c}"/>
                    </apex:outputText>
                </apex:column>
                <apex:column>
                    <apex:facet name="header">Date of Leaving</apex:facet>
                    <apex:outputText value="{0, date, MMM '-' d '-' yyyy}">
                        <apex:param value="{!em.Date_of_Leaving__c}"/>
                    </apex:outputText>
                </apex:column>
                <apex:column>
                    <apex:facet name="header">Thumbnail</apex:facet>
                    <apex:outputText value="{!em.Thumbnail__c}"/>
                </apex:column>
            </apex:dataTable>
        </apex:pageBlock>
    </apex:form>    
</apex:page>
Below is how it will look.
User-added image
Thanks, Sunil.