This is a migrated thread and some comments may be shown as answers.

SuggestionsSource

5 Answers 37 Views
AutocompleteBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Carlos
Top achievements
Rank 1
Carlos asked on 27 Aug 2013, 10:07 AM
Hi,

I am trying to change the SuggestionsSource property when the user types a certain text. For that I have set the TextChanged event to identify when the typed text is the one I'm looking for. When that happens, I update the SuggestionsSource property with a new list of strings but the autocomplete box still uses the old object for SuggestionsSource. It is only when I type another char that the source appears updated in the UI.

The update of the SuggestionsSource property is done within Dispatcher.BeginInvoke.

Is this approach correct to achieve the change of SuggestionsSource property on runtime?

Best,
Carlos.

5 Answers, 1 is accepted

Sort by
0
Deyan
Telerik team
answered on 27 Aug 2013, 02:56 PM
Hi Carlos,

Thanks for writing.

The scenario you are trying to implement is not officially supported. When the TextChanged event is fired the AutoCompleteBox has already processed the input based on the existing source. When you change the source, the subsequent inputs will be processed in its context.

Could you please share some more details on why would you want to change the source?

Regards,
Deyan
Telerik
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
0
Carlos
Top achievements
Rank 1
answered on 28 Aug 2013, 04:13 PM
Hi,

thanks a lot for the prompt response.

The App I'm working on has a search feature. The users is shown search suggestions based on what she types. In this scenario we have then two types of suggestions, local suggestions (saved within the App as a text file) and remote suggestions (generated from a server when local suggestions deliver no result). At the moment when local suggestions can't deliver any text, a new set of strings is fetched from a remote server. When this is done so, the SuggestionsSource property has to be change to make use of the new ones.

Is there any way of achieving this some other way than updating the SuggestionsSource property? 

Best,
Carlos.
0
Deyan
Telerik team
answered on 02 Sep 2013, 07:39 AM
Hi Carlos,

Thanks for writing back and for the requested details.

RadAutoCompleteBox supports updating the SuggestionsSource by simply appending new items to it. If you use an ObservableCollection as a suggestion source, you will be able to add new suggestions in the source collection and filter against them when the users provide new input.

Can you please try using this approach and let me know if it works for you?

Regards,
Deyan
Telerik
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
0
Carlos
Top achievements
Rank 1
answered on 02 Sep 2013, 04:01 PM
Hi Deyan,

thanks for your answer.

Your suggestion has solved the problem but now I have another one. I use Clear on the ObservableCollection to remove all strings. That method seems to be confusing the RadAutocompleteBox because then suggestions stop to appear on the screen although new ones were loaded.

Is there any known issue with ObservableCollection and Clear method when updating the SuggestionsSource property?

Best,
Carlos.
0
Deyan
Telerik team
answered on 03 Sep 2013, 08:53 AM
Hi Carlos,

Thanks for writing back.

There might be a small bug which causes this behavior and we are willing to take a look at it. Could you please share your project which we can use to debug the scenario and see how we can address the glitch?

You will have to open a new support ticket in order to be able to do that.

Regards,
Deyan
Telerik
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
Tags
AutocompleteBox
Asked by
Carlos
Top achievements
Rank 1
Answers by
Deyan
Telerik team
Carlos
Top achievements
Rank 1
Share this question
or