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
BCSFDC1974BCSFDC1974 

Multi-Select List

Hey Guys,

 

Is there a sample of doing a multi-select list in VF just like the built in one where you can move values back and forth between a selected and unselected boxes?

 

Thanks

 

Best Answer chosen by Admin (Salesforce Developers) 
BCSFDC1974BCSFDC1974
I am assuming if you want to bind the select list to a custom data query you would have to use the 2nd option?

All Answers

BCSFDC1974BCSFDC1974
Nobody has done this?
sfdcfoxsfdcfox

Personally, I have not done this, but it certainly can be done. There's two ways you can go about this, and the choice is yours.

 

1) Bind to the existing UI by using the inputField tag.

 

 

<apex:inputField value="{!myObject.myMultiSelectField__c}" />

If the field is on an object, just bind to it and Salesforce will automatically oblige you with a complete multi-select mock-up.

 

2) Roll your own design.

 

 

<apex:selectList size="6" multiselect="true" value="{!availableValues}">

<apex:selectOptions value="{!availableValueList}" /></apex:selectList><apex:commandLink action="{!addValues}" reRender="theForm"><apex:image ... /></apex:commandLink><apex:commandLink action="{!removeValues}" reRender="theForm"><apex:image ... /></apex:commandLink><apex:selectList size="6" multiselect="true" value="{!selectedValues}"> <apex:selectOptions value="{!selectedValueList}" /></apex:selectList>

 

This one requires a custom controller with four get/set methods, two other methods, and a liberal dose of CSS, or at least figuring out Salesforce's CSS classes (not included here for brevity).

 

 

 

 

BCSFDC1974BCSFDC1974
I am assuming if you want to bind the select list to a custom data query you would have to use the 2nd option?
This was selected as the best answer
reatlimecoreatlimeco
What is the typing on availableValues?