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 data with multi-select

I am trying to create a multi-select SfAutoComplete that queries a REST API as the user types.

I have this semi-working for a single item, but there is a fatal flaw when using multi-select and tokens...

I have tried two options to capture a user's input. One is using the "ValueChanged" event to trigger a call to my REST API, and another is 2-way databinding the "Text" field and then using the setter to trigger the REST API call.

For example, I can search for the name "Alex" from a list. I type "Alex" and it shows that suggestion from my API. I select it, and it adds this token to the typing area of the AutoComplete. The problem is, this triggers ValueChanged as well as the "Text" setter. It tries to make another call to my API with the full text of the typing area.

3 Replies

MK Muneesh Kumar G Syncfusion Team July 3, 2019 11:53 AM UTC

Hi Alex, 
Greetings from Syncfusion.  
In AutoComplete, whenever a selection is made from the dropdown or type the text in the editor we have updated SfAutoComplete Text property and raised the ValueChanged event. We suggest you to call your Rest API any of these one place. 
We have checked the reported issue "Fatal flaw when using multi-select and tokens when using REST API" from our side.  We need more detail about your application to analyze this issue further. So, could you please provide the simple sample based on your application which replicates the reported issue. 
This will be helpful for us to investigate further and provide you a better solution at the earliest. 
Muneesh Kumar G.    

AL Alex July 3, 2019 05:22 PM UTC

Here I have provided an example that just searches iTunes API for track names.

To reproduce:
  1. Type the name of a popular song like "Hello"
  2. The ValueChanged event will fire every time you type a character and query iTunes
  3. Select a result from the suggestions
  4. The ValueChanged event will fire again because you've changed the value of the textbox
  5. The token will be removed for some reason
  6. Even if the token stayed, if I want to type a second name, like "All Time", the value I get in "ValueChanged" will now be "HelloAll Time". 
The problem is that the "Value" contains what you're typing as well as existing token's text. This means I can't capture the value of what someone is typing without having to manually strip out the other tokens.

Attachment: AutoCompleteTest_ad9bef7e.zip

MK Muneesh Kumar G Syncfusion Team July 4, 2019 01:25 PM UTC

Hi Alex, 
We have checked the attached sample and we would like to let you know that the tokens have been cleared since when the results are being cleared in the following method LoadResultsAsync. Hence, we have removed the same and attached the sample. 
And also when the next item is clicked the Value we got is the current text in the autocomplete. We have recorded a video from which we incurred the solution. Please have the video link, 
Please check with the video and if the mentioned behavior differs from the video please, provide a video representation which will be helpful for us to analyze further and provide an appropriate solution. 
Muneesh Kumar G.  

Live Chat Icon For mobile
Up arrow icon