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
monikamonika 

preset selected values for lightning:dualListbox

How can I get lightning:dualListbox to show preselected list of values? I've tried what I've seen on developer's blogs but for some reason my right list is always empty. (API v.43)
 
​<aura:attribute name="countryOptions" type="List" default="[
                                                               { label: 'United Kingdom', value: 'GB' },
                                                               { label: 'Netherlands', value: 'NL' }]"/>

<aura:attribute name="existingValues" type="List" default="[ {label: 'United Kingdom', value: 'GB' }]" />

   
<lightning:dualListbox  label= "Select Country"  sourceLabel="Available"  selectedLabel="Selected" 
                                              options="{!v.countryOptions}" 
                                              value="{!v.existingValues}"/>

 
Hemendra Malik 16Hemendra Malik 16
In value it accepts list of string. Please define attribute as - 
<aura:attribute name="existingValues" type="List" default="['United Kingdom','GB' ]" />

now this should work fine..