How to set selected items on load of AutoComplete

Hi,

The data source for my AutoComplete includes a flag, "IsChecked"
How do I make the AutoComplete create the visual labels (I'm using the MultiSelectModeTypes.VisualMode)
So they appear preselected.

Thanks!

1 Reply

BS Buvana Sathasivam Syncfusion Team November 30, 2017 04:44 PM UTC

Hi Sam, 
  
Thanks for using Syncfusion Products. 
  
We have analyzed your requirement.  Our autocomplete doesn't support for preselected data using data source.  So, we suggest you to use dropdown list for achieving your requirement.  We have created dropdown list with preselected and visual mode using data source selected field value. 
  
DropdownlistFeatures.cshtml 
  
  @Html.EJ().DropDownList("DropDownList1").Datasource((IEnumerable<Data>)ViewData["DropDownSource"]).DropDownListFields(Df => Df.Text("Text").Value("Value").Selected("Selected")).Width("300px").MultiSelectMode(MultiSelectModeTypes.VisualMode) 
// Created drop down list with visual mode 
  
  
DropdownlistController.cs 
  
List<Data> DropDownData = new List<Data>(); 
        public ActionResult DropdownlistFeatures() // Drop down data 
        {  
            DropDownData.Add(new Data { Value = "item1", Text = "ListItem 1", Selected = true }); 
            DropDownData.Add(new Data { Value = "item2", Text = "ListItem 2", Selected = false }); 
            DropDownData.Add(new Data { Value = "item3", Text = "ListItem 3", Selected = true }); 
            DropDownData.Add(new Data { Value = "item4", Text = "ListItem 4", Selected = false }); 
            DropDownData.Add(new Data { Value = "item5", Text = "ListItem 5", Selected = false }); 
            ViewData["DropDownSource"] = DropDownData; 
            return View(); 
        } 
  
   public class Data 
    { 
        public string Value { get; set; } 
        public string Text { get; set; } 
        public bool Selected { get; set; } // set selected as Boolean type 
    } 
  
  
  
For your convenience, we have prepared a simple sample. Please find the below sample. 
  
  
Regards, 
Buvana S. 


Loader.
Up arrow icon