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

SelectedItem values not updated correctly


Hi,
I have a page with the SfAutoComplete control and a button. SfAutoComplete is bound to a ObservableCollection for DataSource and SelectedItem.
Clicking on the button navigates to a page with a list of items. Once the item is selected I update the ObservableCollection  for the SelectedItem with the newly added items.
I then use PopAsync to get back to the main page.
The newly added items are not visible in SfAutoComplete's selected list. I checked the OnAppearing of the main page and I can see that the ObservableCollection has the new items. It is just not displayed.

Now a slight change to the above process-
I start typing into the SfAutoComplete control and select one of the suggested items. This is added to the SfAutoComplete's selected list.
Now I click on the add button and navigate to the list view and select another item from there.
In this case the new item is added correctly.

What could be wrong?
Is there a way to manually force the SfAutoComplete to update it's SelectedItem values - I tried a few ways on the OnAppearing but it did not work.
Is there a way to refresh the SfAutoComplete's SelectedItem list manually from code behind?

Thanks!

3 Replies

MK Muneesh Kumar G Syncfusion Team September 26, 2019 12:36 PM UTC

Hi SP,

Greetings from Syncfusion.


 
Query: Clicking on the button navigates to a page with a list of items. Once the item is selected I update the ObservableCollection  for the SelectedItem with the newly added items.

 
We have analyzed your query, but we can’t get exact scenario from this. Because list of items has not been mentioned in the next page. 
 
We have prepared a sample with SfAutoComplete and Button. And with Button Click, we have added new collection and set the SelectedItem. Please have the sample from the below link,

Sample Link: 
 

Please check with the above sample and if the mentioned scenario differs from the above, please modify the sample based on your application and update us below details.

1) Please confirm the MultiSelect mode used or not

2) Update us the platform details.
 
 
Thanks,     
Muneesh Kumar G.     
 



SP SP September 26, 2019 06:06 PM UTC

Thanks. I was able to solve this using MessagingCenter and the autocomplete's SelectionChanged event.
I am using multiselect.
I am testing on Android.


MK Muneesh Kumar G Syncfusion Team September 27, 2019 05:57 AM UTC

Hi SP, 
 
Thanks for the update. 
  
We are glad to know that the given solution works. Please let us know if you need any further assistance. 
 
Thanks, 
Muneesh Kumar G. 


Loader.
Live Chat Icon For mobile
Up arrow icon