We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Dynamically load list

Hi,

I have the list to choose from that I'm loading from API. I would prefer to implement server side search and load only items for auto-complete as user types in case list is very large.

What would be the best way of doing it using SfAutoComplete control? What event should I use to update the list (I'm using DataSource property to bind to the list), or return the list of object?

Thanks.

3 Replies

DR Dhanasekar R Syncfusion Team December 31, 2018 10:33 AM UTC

Hi Maxim, 
 
Greetings from Syncfusion. 

Query: What event should I use to update the list 
  
We have validated your query and you can use DataSource property to have the Collection of items on SfAutoComplete DropDown. We have prepared a sample in which we have used online API and by using RestService we will get the data from the link when the user types any letter in AutoComplete 
 
  async void GetData(string cityCode)
        {
            //To set DataSource to the AutoComplete Control
            ItemsSource = await restservice.RefreshDataAsync(cityCode);
                .
                .
                .
         } 
 
  public async System.Threading.Tasks.Task<ObservableCollection<Post>> RefreshDataAsync(string cityPinCode)
        {
            //Adding URL data to the DataSource of AutoComplete
            areaCollection = new ObservableCollection<Post>();
            RestUrl = "https://jsonplaceholder.typicode.com/todos/" + cityPinCode;
            var uri = new Uri(RestUrl);
        } 
 
 
Please download the sample from below link. 
 
Sample link: AutoCompleteSample 
 
Please let us know if you have any further clarifications on this. 
 
Regards, 
Dhanasekar 



MA Maxim Alexeyev December 31, 2018 03:04 PM UTC

Thank you, I will give it a try.


DR Dhanasekar R Syncfusion Team January 2, 2019 09:57 AM UTC

Hi Maxim,   
    
Thanks for your update, take your time and we will wait to hear from you.    
    
Regards,   
Dhanasekar 
 


Loader.
Live Chat Icon For mobile
Up arrow icon