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
sanshasansha 

selectList to look like an input field of type multiselect

Consider the following data:
 
Name1:GroupA
Name2:GroupA
Name3:GroupB
Name4:GroupB
Name5:GroupB
 
I need to have a multiselect picklist having data based on the Group selected in some other picklist. e.g. if GroupB is selected then the multiselect picklist should show the values Name3, Name4, Name5.
 
I was thinking of creating a separate object having two columns Name and Group. This object would then be used to create a lookup field. I then create a selectList and then filter the values in the selectList based on the Group selected. However I want the selectList to look like a multiselect picklist (having the Available and Selected boxes with the arrows in between). Is that possible ?
 
Please let me know how to achieve this or is there any other method on doing this ?
Luke@TWSLuke@TWS
You can do this with a selectList that has an actionSupport child element. This would call an action to change the selectOptions in the multi-select list and have the rerender attribute set to the multi-select list id
sanshasansha
Is it possible to change the options in the inputfield of type multiselect picklist ? Can you please point me to some examples?
Luke@TWSLuke@TWS
You just need to call a function to change the elements that the multi select list gets. Eg:

Code:
private List<SelectOption> mySelectOptions;

private void populate() {
mySelectOptions.add(new SelectOption('ObjectA','ObjectA'));
mySelectOptions.add(new SelectOption('ObjectB','ObjectB'));
mySelectOptions.add(new SelectOption('ObjectC','ObjectC'));
}

public List<SelectOption> getMySelectOptions() {
if (mySelectOptions == null) populate();
return mySelectOptions;
}

public void changeOptions() {
mySelectOptions.remove(0);
mySelectOptions.add(new SelectOption('ObjectD','ObjectD'));
}

 Just have the value of the selectOptions set to {!mySelectOptions} and an actionSupport for the onchange method of the first list to call the action {!changeOptions}