Pre-selecting a value in multiselectdropdown where mode = checkbox

i am trying to set a default value to the multiselectdropdown where property "mode" is set to "checkbox"  (

i cant seem to have the checkbox ticked when i set "value = {["example"]}"

<MultiSelectComponent
    dataSource = {datasource}
    mode = "Checkbox"
    value = {["example selected"]}
>
<Inject services = {[CheckboxSelection]}/>

</MultiSelectComponent>


conversely, it works when "mode" = "default" or "box"

<MultiSelectComponent
    dataSource = {datasource}
    mode = "Default"
    value = {["example selected"]}
>

</MultiSelectComponent>



1 Reply

PM Ponmani Murugaiyan Syncfusion Team February 16, 2022 09:25 AM UTC

Hi lionel, 

We have prepared sample for preselecting a value in the Multiselect checkbox mode. 


constructor() { 
  super(...arguments); 
  ... 
  this.checkFields = { text: 'Name', value: 'Code' }; 
  this.value = ['DK', 'IN']; 
} 
 
 
<MultiSelectComponent 
id="checkbox" 
ref={(scope) => { 
  this.mulObj = scope; 
}} 
dataSource={this.countries} 
fields={this.checkFields} 
placeholder="Select countries" 
mode="CheckBox" 
showSelectAll={true} 
showDropDownIcon={true} 
filterBarPlaceholder="Search countries" 
popupHeight="350px" 
value={this.value} 
> 
<Inject services={[CheckBoxSelection]} /> 
</MultiSelectComponent> 


Regards, 
Ponmani M 


Loader.
Up arrow icon