Monday, July 3, 2017

How To Dispaly The DropDown Values With CheckBoxes Vertically In Visual Force

In my previous post I have explained to how to display the drop down values with check boxes so we will use the same post but In this post I will explain how to display that list vertically rather than horizontally.

In <apex:SelectCheckBoxes> tag we have an attribute called 'layout' which will decides the direction of the display .If you set that to layout="pageDirection" then it will displays automatically in vertical.

Source Code:


In VisualForce Page:

<apex:selectcheckBoxes value="{!selFruits}" layout="pageDirection">
 <apex:selectOption itemLabel="Mango" itemValue="Mango" />
 <apex:selectOption itemLabel="Apple" itemValue="Apple" />
 <apex:selectOption itemLabel="Banana" itemValue="Banana" />
 <apex:selectOption itemLabel="Guava" itemValue="Guava"/>
        <apex:selectOption itemLabel="Orange" itemValue="Orange"/>

</apex:selectcheckBoxes>

In Apex Class:

Public List<String> selFruits{get;set;} // This should be list not Single String


OutPut:




Thanks for visiting..hope this helps you!

No comments:

Post a Comment