0

I have a requirement to show colored backgrounds for column headers of tables. Can someone suggest a way out without using pageblocktable?

Please find my controller class here.

public class IncidentDetailExtnController{
    Incident__c oInc {get;set;}
    Id recId;
    public List<Incident_Transaction__c> oIncTranListHCPDetail {get;set;}
    public List<Incident_Transaction__c> oIncTranListHCI {get;set;}
    public List<Incident_Transaction__c> oIncTranListPharmacy{get;set;}
    public List<Incident_Transaction__c>oIncTranListHCPSamples{get;set;}
    public List<Incident_Transaction__c>oIncTranListHCPSpeaker{get;set;}
        public List<Incident_Transaction__c>oIncTranListSynch{get;set;}
    public String profName{get;set;}
    public Map<id,String> MapIncTxn{get;set;}
        public Boolean k{get;set;}
    public IncidentDetailExtnController(ApexPages.StandardController controller) 
    {
        recId =ApexPages.CurrentPage().getparameters().get('Id');
        oInc = (Incident__c) controller.getRecord();
        oIncTranListHCPDetail = [SELECT Account_Abs_abv__c,Account_Location_abv__c,Attendee_Role_abv__c ,Prof_City_abv__c,Prof_zip_abv__c,Associated_Prescriber_ID_abv__r.Name,Account_Name_abv__c ,
                                Call_Detail_abv__c , Call_Detail_abv__r.Product_vod__c ,Prof_Address_Line2_abv__c, Call_Detail_abv__r.Call2_vod__c , Call_Detail_abv__r.Call2_vod__r.Call_Date_vod__c , 
                                Call_Detail_abv__r.Call2_vod__r.Associated_Prescriber_ABS_CIA__c , Call_Detail_abv__r.Call2_vod__r.Associated_Prescriber_CIA__r.Name , Prof_state_abv__c,
                                Call_Detail_abv__r.Call2_vod__r.Account_vod__r.Name , Call_Detail_abv__r.Call2_vod__r.Address_vod__c , Call_Detail_abv__r.Type_vod__c , 
                                Call_Sample_abv__c , Call_Sample_abv__r.Account_vod__r.Name , Call_Sample_abv__r.Call2_vod__c , Call_Sample_abv__r.Call2_vod__r.Activity_Type__c , 
                                Call_Sample_abv__r.Call2_vod__r.Address_vod__c , Call_Sample_abv__r.Call2_vod__r.Associated_Prescriber_ABS_CIA__c , id,
                                Call_Sample_abv__r.Call2_vod__r.Associated_Prescriber_CIA__r.Name , Call_Sample_abv__r.Call2_vod__r.Call_Date_vod__c , 
                                Call_Sample_abv__r.Quantity_vod__c , Call_Sample_abv__r.Product_vod__c , Call_Sample_abv__r.Product_vod__r.Product_Type_vod__c , 
                                Date_of_Last_Sync_abv__c , Date_of_Prev_Sync_abv__c , Days_bwn_Sync_abv__c , Outcome_abv__c , Transaction_type__c , Call__c , 
                                Call__r.Account_vod__r.Name , Call__r.Associated_Prescriber_ABS_CIA__c , Call__r.Associated_Prescriber_CIA__r.Name , Call__r.Call_Date_vod__c , 
                                Call__r.Address_vod__c, Call__r.Detailed_Products_vod__c,Prof_First_Name_abv__c,Prof_Middle_Name_abv__c,Prof_Last_Name_abv__c,Prof_Address_Line1_abv__c
                                 FROM Incident_Transaction__c where Incident__c = :recId and Transaction_type__c=:'HCP Calls'];


              oIncTranListHCI = [SELECT ABBT_Customer_Id_abv__c, Account_Abs_abv__c,Associated_Prescriber_ID_abv__r.Name, Account_Location_abv__c, Account_Name_abv__c, Associated_Account_Name_abv__c, 
            Associated_HCP_Name_abv__c, Associated_Prescriber_ID_abv__c, Attendee_Role_abv__c, Call__c, Call_Detail_abv__c, Call_Sample_abv__c, CreatedById, CreatedDate, Date_of_Last_Sync_abv__c, Date_of_Prev_Sync_abv__c, Days_bwn_Sync_abv__c, IsDeleted, Event_Location_abv__c, Event_Topic_abv__c, Incident__c, Inc_Transaction_ID_abv__c, Name, IsLocked, LastActivityDate, LastModifiedById, LastModifiedDate, MayEdit, Medical_Event_abv__c, Outcome_abv__c, Outcome_Date_abv__c, Outcome_Selected_By_User_Name_abv__c, Outcome_selected_By_User_ID_abv__c, Prof_Abs_abv__c, Prof_Address_Line1_abv__c, Prof_Address_Line2_abv__c
            ,Prof_City_abv__c ,Prof_Designation_abv__c, Prof_First_Name_abv__c, Prof_Last_Name_abv__c, Prof_Middle_Name_abv__c, Prof_State_abv__c, Prof_Zip_abv__c, Id, SystemModstamp, Transaction_Date_abv__c, Transaction_type__c 
            FROM Incident_Transaction__c where Incident__c = :recId and Transaction_type__c=:'HIC/HCO Calls'];
            //Type =Pharmacy
            oIncTranListPharmacy= [SELECT ABBT_Customer_Id_abv__c, Account_Abs_abv__c, Account_Location_abv__c,Associated_Prescriber_ID_abv__r.Name, Account_Name_abv__c, Associated_Account_Name_abv__c, 
            Associated_HCP_Name_abv__c, Associated_Prescriber_ID_abv__c, Attendee_Role_abv__c, Call__c, Call_Detail_abv__c, Call_Sample_abv__c, CreatedById, CreatedDate, Date_of_Last_Sync_abv__c, Date_of_Prev_Sync_abv__c, Days_bwn_Sync_abv__c, IsDeleted, Event_Location_abv__c, Event_Topic_abv__c, Incident__c, Inc_Transaction_ID_abv__c, Name, IsLocked, LastActivityDate, LastModifiedById, LastModifiedDate, MayEdit, Medical_Event_abv__c, Outcome_abv__c, Outcome_Date_abv__c, Outcome_Selected_By_User_Name_abv__c, Outcome_selected_By_User_ID_abv__c, Prof_Abs_abv__c, Prof_Address_Line1_abv__c, Prof_Address_Line2_abv__c, Prof_City_abv__c, Prof_Designation_abv__c, Prof_First_Name_abv__c, Prof_Last_Name_abv__c, Prof_Middle_Name_abv__c, Prof_State_abv__c, Prof_Zip_abv__c, Id, SystemModstamp, Transaction_Date_abv__c, Transaction_type__c 
            FROM Incident_Transaction__c where Incident__c = :recId and Transaction_type__c=:'Pharmacy Calls'];

            oIncTranListHCPSamples = [SELECT ABBT_Customer_Id_abv__c, Account_Abs_abv__c, Account_Location_abv__c,Associated_Prescriber_ID_abv__r.Name, Account_Name_abv__c, Associated_Account_Name_abv__c, 
            Associated_HCP_Name_abv__c, Associated_Prescriber_ID_abv__c, Attendee_Role_abv__c, Call__c, Call_Detail_abv__c, Call_Sample_abv__c, CreatedById, CreatedDate, Date_of_Last_Sync_abv__c, Date_of_Prev_Sync_abv__c, Days_bwn_Sync_abv__c, IsDeleted, Event_Location_abv__c, Event_Topic_abv__c, Incident__c, Inc_Transaction_ID_abv__c, Name, IsLocked, LastActivityDate, LastModifiedById, LastModifiedDate, MayEdit, Medical_Event_abv__c, Outcome_abv__c, Outcome_Date_abv__c, Outcome_Selected_By_User_Name_abv__c, Outcome_selected_By_User_ID_abv__c, Prof_Abs_abv__c, Prof_Address_Line1_abv__c, Prof_Address_Line2_abv__c, Prof_City_abv__c, Prof_Designation_abv__c, Prof_First_Name_abv__c, Prof_Last_Name_abv__c, Prof_Middle_Name_abv__c, Prof_State_abv__c, Prof_Zip_abv__c, Id, SystemModstamp, Transaction_Date_abv__c, Transaction_type__c 
            FROM Incident_Transaction__c where Incident__c = :recId and Transaction_type__c=:'Samples'];

            oIncTranListHCPSpeaker = [SELECT ABBT_Customer_Id_abv__c, Account_Abs_abv__c,Associated_Prescriber_ID_abv__r.Name, Account_Location_abv__c, Account_Name_abv__c, Associated_Account_Name_abv__c, 
            Associated_HCP_Name_abv__c, Associated_Prescriber_ID_abv__c, Attendee_Role_abv__c, Call__c, Call_Detail_abv__c, Call_Sample_abv__c, CreatedById, CreatedDate, Date_of_Last_Sync_abv__c, Date_of_Prev_Sync_abv__c, Days_bwn_Sync_abv__c, IsDeleted, Event_Location_abv__c, Event_Topic_abv__c, Incident__c, Inc_Transaction_ID_abv__c, Name, IsLocked, LastActivityDate, LastModifiedById, LastModifiedDate, MayEdit, Medical_Event_abv__c, Outcome_abv__c, Outcome_Date_abv__c, Outcome_Selected_By_User_Name_abv__c, Outcome_selected_By_User_ID_abv__c, Prof_Abs_abv__c, Prof_Address_Line1_abv__c, Prof_Address_Line2_abv__c, Prof_City_abv__c, Prof_Designation_abv__c, Prof_First_Name_abv__c, Prof_Last_Name_abv__c, Prof_Middle_Name_abv__c, Prof_State_abv__c, Prof_Zip_abv__c, Id, SystemModstamp, Transaction_Date_abv__c, Transaction_type__c 
            FROM Incident_Transaction__c where Incident__c = :recId and Transaction_type__c=:'Speaker Program Attendees'];

            oIncTranListSynch = [SELECT ABBT_Customer_Id_abv__c, Account_Abs_abv__c,Associated_Prescriber_ID_abv__r.Name, Account_Location_abv__c, Account_Name_abv__c, Associated_Account_Name_abv__c, 
            Associated_HCP_Name_abv__c, Associated_Prescriber_ID_abv__c, Attendee_Role_abv__c, Call__c, Call_Detail_abv__c, Call_Sample_abv__c, CreatedById, CreatedDate, Date_of_Last_Sync_abv__c, Date_of_Prev_Sync_abv__c, Days_bwn_Sync_abv__c, IsDeleted, Event_Location_abv__c, Event_Topic_abv__c, Incident__c, Inc_Transaction_ID_abv__c, Name, IsLocked, LastActivityDate, LastModifiedById, LastModifiedDate, MayEdit, Medical_Event_abv__c, Outcome_abv__c, Outcome_Date_abv__c, Outcome_Selected_By_User_Name_abv__c, Outcome_selected_By_User_ID_abv__c, Prof_Abs_abv__c, Prof_Address_Line1_abv__c, Prof_Address_Line2_abv__c, Prof_City_abv__c, Prof_Designation_abv__c, Prof_First_Name_abv__c, Prof_Last_Name_abv__c, Prof_Middle_Name_abv__c, Prof_State_abv__c, Prof_Zip_abv__c, Id, SystemModstamp, Transaction_Date_abv__c, Transaction_type__c 
            FROM Incident_Transaction__c where Incident__c = :recId and Transaction_type__c=:'Synch Rate report'];



   Map<id,String> MapIncTxn= new Map<id,String>();   

   for(   Incident_Transaction__c IT :oIncTranListHCPDetail )
   {
   profName=IT.Prof_First_Name_abv__c+' '+IT.Prof_Middle_Name_abv__c+' '+IT.Prof_Last_Name_abv__c;
   MapIncTxn.put(IT.id,profName);

   }


    }   //constr ends  
    public PageReference attest()
    {

        return null;
    }   
}

Apex page:

<apex:page standardController="Incident__c" extensions="IncidentDetailExtnController" renderAs="pdf"  applyBodyTag="false">
<html>
<style type="text/css" media="print">
  .TableTitle {
    background-color: red!important; 
    font-size:100% !important; 
  }

</style>
</html>
   <apex:pageBlock title="Incident Detail">
        <apex:pageBlockSection columns="2">
            <apex:outputField value="{!Incident__c.Name}"  styleClass="TableTitle"/>
            <apex:outputField value="{!Incident__c.Rep_Lookup_id__c}"/>
            <apex:outputField value="{!Incident__c.Report_Publish_date__c}"/>
            <apex:outputField value="{!Incident__c.Status_abv__c}"/>
            <apex:outputField value="{!Incident__c.No_Of_Transactions_abv__c}"/>                                                
        </apex:pageBlockSection>
    </apex:pageBlock>   

    <apex:pageBlock title="Incident Transactions">
        <!--<apex:tabPanel switchType="client">-->

            <!--<apex:tab label="HCP Calls">
            <a href="http://www.tutorialspoint.com" target="_blank">Tutorials Point</a>
            <!--<a href="http://www.tutorialspoint.com" target="_blank">Tutorials Point</a>
            <a href="http://www.tutorialspoint.com" target="_self">Tutorials Point</a>--!-->


           <!-- <apex:tab label="Samples">
            <a href="http://www.tutorialspoint.com" target="_self">Tutorials Point</a>
            </apex:tab>
            <apex:tab label="Speaker Program Attendees">

            </apex:tab>
            <apex:tab label="Synch Rate">

            </apex:tab>                               
        </apex:tabPanel>-->


        <apex:pageBlockSection title="HCP Calls"  collapsible="true">
        <apex:pageBlockTable columns="9" value="{!oIncTranListHCPDetail}" border="true" var="itr" cellPadding="4" >
        <apex:column headerValue="Professional Name" styleClass="TableTitle" value="{!itr.Prof_First_Name_abv__c} {!itr.Prof_Middle_Name_abv__c} {!itr.Prof_Last_Name_abv__c}" />

         <!-- Need to put Profname string here from the map -->
        <apex:column headerValue=" ABS on Call" styleClass="TableTitle"/> 
        <apex:column value="{!itr.Account_Abs_abv__c}" /> 
        <apex:column headerValue=" Professional Address" />
        <apex:column value="{!itr.Prof_Address_Line1_abv__c}" /> 
        <apex:column headerValue=" Associated Prescriber" value="{!itr.Associated_Prescriber_ID_abv__c}" />
        <apex:column headerValue=" Product" value="{!itr.Account_Abs_abv__c}" />
        <apex:column headerValue=" Activity Date" value="{!itr.Account_Abs_abv__c}" /> 
        <apex:column headerValue=" Outcome - LOV" value="{!itr.Outcome_abv__c}" />



        </apex:pageBlockTable>
        </apex:pageBlockSection>

        <apex:pageBlockSection title="Samples" columns="4">
        <apex:pageBlockTable columns="10" value="{!oIncTranListHCPDetail}" border="true" var="itr" cellPadding="4" >
        <apex:column headerValue="Sample Type" value="{!itr.Prof_First_Name_abv__c}" />
        <apex:column headerValue="Professional Name" value="{!itr.Prof_First_Name_abv__c} {!itr.Prof_Middle_Name_abv__c}  {!itr.Prof_Last_Name_abv__c}" />
        <apex:column headerValue="ABS on Call" value="{!itr.Account_Abs_abv__c}" />
        <apex:column headerValue="Professional Address" value="{!itr.Prof_Address_Line1_abv__c}" />
        <apex:column headerValue="Product" value="{!itr.Prof_First_Name_abv__c}" />
        <apex:column headerValue="Activity Date" value="{!itr.Prof_First_Name_abv__c}" />
        <apex:column headerValue="Quantity (for hand samples, ESR, and DTP/BRC tied to rep)" value="{!itr.Prof_First_Name_abv__c}" />
        <apex:column headerValue="Outcome - LOV" value="{!itr.Outcome_abv__c}" />

        </apex:pageBlockTable>
        </apex:pageBlockSection>
        <apex:pageBlockSection title="Speaker Program Attendees" columns="4">

         <apex:pageBlockTable columns="9" value="{!oIncTranListHCPDetail}" border="true" var="itr" cellPadding="4" >
        <apex:column headerValue="Professional Name" value="{!itr.Prof_First_Name_abv__c} {!itr.Prof_Middle_Name_abv__c}  {!itr.Prof_Last_Name_abv__c}" />
        <apex:column headerValue="ABS on Call" value="{!itr.Account_Abs_abv__c}" />
        <apex:column headerValue="Professional Address" value="{!itr.Prof_Address_Line1_abv__c}" />
        <apex:column headerValue="Product" value="{!itr.Prof_First_Name_abv__c}" />
        <apex:column headerValue="Activity Date" value="{!itr.Prof_First_Name_abv__c}" />
        <apex:column headerValue="Program Name, Date and Location" value="{!itr.Prof_First_Name_abv__c}" />
        <apex:column headerValue="Outcome - LOV" value="{!itr.Outcome_abv__c}" />

        </apex:pageBlockTable>
        </apex:pageBlockSection>

        <apex:pageBlockSection title="Synch report" columns="4">

         <apex:pageBlockTable columns="6" value="{!oIncTranListHCPDetail}" border="true" var="itr" cellPadding="4" >
        <apex:column headerValue="Date of Previous Synchronization" value="{!itr.Date_of_Prev_Sync_abv__c}" />
        <apex:column headerValue="Date of Last Synchronization" value="{!itr.Date_of_Last_Sync_abv__c}" />
        <apex:column headerValue="Days between Synchronization" value="{!itr.Days_bwn_Sync_abv__c}" />
        <apex:column headerValue="Outcome - LOV" value="{!itr.Outcome_abv__c}" />

        </apex:pageBlockTable>
        </apex:pageBlockSection>


        <apex:pageBlockSection title="HCI/HCO Calls" columns="6">

         <apex:pageBlockTable columns="10" value="{!oIncTranListHCPDetail}" border="true" var="itr" cellPadding="4" >
        <apex:column headerValue="Account Name" value="{!itr.Account_Name_abv__c}" />
        <apex:column headerValue="ABS on Call" value="{!itr.Account_Abs_abv__c}" />
        <apex:column headerValue="Account Address" value="{!itr.Account_Location_abv__c}" />
        <apex:column headerValue="Attendee Name" value="{!itr.Prof_First_Name_abv__c}" />
        <apex:column headerValue="Attendee Role" value="{!itr.Attendee_Role_abv__c}" />
        <apex:column headerValue="Detail" value="{!itr.Prof_First_Name_abv__c}" />
        <apex:column headerValue="Activity Date" value="{!itr.Prof_First_Name_abv__c}" />
        <apex:column headerValue="Outcome - LOV" value="{!itr.Outcome_abv__c}" />

        </apex:pageBlockTable>
        </apex:pageBlockSection>

         <apex:pageBlock title="">

         </apex:pageBlock>

        <apex:pageBlockSection title="Pharmacy Calls" columns="4">

         <apex:pageBlockTable columns="10" value="{!oIncTranListHCPDetail}" border="true" var="itr" cellPadding="4" >
        <apex:column headerValue="Account Name" value="{!itr.Account_Name_abv__c}" />
        <apex:column headerValue="ABS on Call" value="{!itr.Account_Abs_abv__c}" />
        <apex:column headerValue="Account Address" value="{!itr.Account_Location_abv__c}" />
        <apex:column headerValue="Attendee Name" value="{!itr.Prof_First_Name_abv__c}" />
        <apex:column headerValue="Attendee Role" value="{!itr.Attendee_Role_abv__c}" />
        <apex:column headerValue="Detail" value="{!itr.Prof_First_Name_abv__c}" />
        <apex:column headerValue="Activity Date" value="{!itr.Prof_First_Name_abv__c}" />
        <apex:column headerValue="Outcome - LOV" value="{!itr.Outcome_abv__c}" />

        </apex:pageBlockTable>
        </apex:pageBlockSection>

    </apex:pageBlock>  

</apex:page>
1

I have PDF output using HTML table tags of this form:

<table>
    <tr>
        <td class="heading">Sample Type</td>
        ...
    </tr>
    <apex:repeat value="{!oIncTranListHCPDetail}" var="itr">
    <tr>
        <td class="cell">{!itr.Prof_First_Name_abv__c}</td>
        ...
    </tr>
    </apex:repeat>
</table>

with CSS defined in a linked CSS static resource that includes definitions such as:

td.heading {
    font-weight: bold;
    text-align: left;
    background-color: #d9edf7;
}

that produces correctly colored backgrounds in the PDF output.

1

In the pageBlockTable you need your background to be painted use css below:

background-color:green

You can include internal css for this or best way is by inline css. This way you can only paint particular table in the page. Example is Below :

<apex:pageBlockTable Style="background-color:green;">

.....

</apex:pageBlockTable>

I hope this might help you.

1
  • This is okay for apex page but when converting into PDF it does not show. Can you please suggest a way here for pdf? Nov 21 '14 at 7:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.