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.
MKMuneesh Kumar G Syncfusion Team July 3, 2019 06:53 AM
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.
ALAlexJuly 3, 2019 12:22 PM
Here I have provided an example that just searches iTunes API for track names.
Type the name of a popular song like "Hello"
The ValueChanged event will fire every time you type a character and query iTunes
Select a result from the suggestions
The ValueChanged event will fire again because you've changed the value of the textbox
The token will be removed for some reason
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.
MKMuneesh Kumar G Syncfusion Team July 4, 2019 08:25 AM
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.
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.