1

I have a requirement to display Picklist values on a Visualforce page (which is rendered as a PDF) and then format them.

Essentially the users print the sheet off and we wanted the person completing the form to check the option with a tick or something nice and obvious like that.

The Code I am using below displays the options with a checkbox EXCEPT when it is rendered as a PDF. It doesn't look horrible but is simply formatted in vertical lists.

My question is; how can I edit the code to either include an image of a checkbox next to each picklist value OR display the actual checkbox?

Code within the controller:

public List<String> caseType{ get; set; }

public List<SelectOption> getCaseType()
{
  List<SelectOption> options = new List<SelectOption>();

   Schema.DescribeFieldResult fieldResult = case.Case_Type.getDescribe();
   List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();

   for( Schema.PicklistEntry f : ple)
   {
      options.add(new SelectOption(f.getLabel(), f.getValue()));
   }       
   return options;
}

Code within the visualforce page:

 <apex:form >   
   <apex:pageBlock >
     <apex:pageBlockSection columns="1"  >
        <apex:pageBlockSectionItem dataStyle="vertical-align:text-top; padding-right:50px; "  >
         <apex:selectcheckboxes layout="pagedirection" value="{!closedReason}" >
         <h3>Please highlight the Case Type</h3>
          <apex:selectoptions value="{!closedReasons}"/>
      </apex:selectcheckboxes>
      </apex:pageBlockSectionItem>
     </apex:pageBlockSection>
  </apex:pageBlock>
 </apex:form> 

I've tried formatting between open and close tags but that didn't work (just displayed it once at the top of the column. Any help and advice is, as always, greatly appreciated.

0

Rendering a pdf is tricky. Do not show <apex:selectCheckBoxes/> as user will not going to select anything on pdf.

You can find 2 images of check box, one for Selected, other for Not-selected. Put them in the static resource.

Rather than showing the checkbox and selectList, you show the image with

<apex:image id="logo1" url="{!$Resource.imgSelected}"/>, followed by the <apex:outputText/>

  • Thanks, I'll try and take a look at changing the apex to do this...bit of a rookie so bare with me! – n34_panda Nov 11 '16 at 9:04
  • @n34_panda, can you pls close this question providing your comments – Santanu Boral Nov 17 '16 at 16:03

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.