ejAutocomplete allows to select more than one option in mutiSelectionMode. By default, it can select same option multiple times. We want to avoid such duplication.
I have tried member 'EnableDistinct'. It does not take effect. According to document, it seems 'select' event can suit my requirement. If selected item has been selected before, we can set 'cancel' as true to cancel this select event. However, it does not work as anticipated.
Could you please give example to illustrate how to use 'EnableDistinct' and 'select event' in aforementioned scenario?
APArun Palaniyandi Syncfusion Team February 24, 2017 07:31 AM UTC
Thanks for contacting Syncfusion Support.
The enableDistinct property is only used to remove the duplicate names present in the search result, and it will not affect the selected value. To achieve your scenario, use the select event as you have tried and use this event to filter the value and then set the value to the input textbox.
Please find below the playground demo link for your reference.
This type of problem will not occur in the multiSelectMode asVisualMode. In this mode, once the value is selected, it will not come again in the suggestion list and hence there are no duplicate values to be selected.
In text box, type 'a', select first item 'Alabama' and type character 'a' immediately, it will show 'Alabama,a' following 'Alabama' option in text box .
And 'enableDistinct' only works for local data source, in enterprise application, we usually refers to remote data source.
In online document https://help.syncfusion.com/api/js/ejautocomplete#events:select, it mentions: Set this option to true to cancel the event. However, I set option as true, 'select' event is not cancelled, it just continues remaining process. Otherwise, 'cancel' would be nice solution to avoid duplicated item.
APArun Palaniyandi Syncfusion Team March 1, 2017 11:10 AM UTC
Thanks for your update.
Query1:” it has bug if I change mode as : ej.MultiSelectMode.VisualMode”
As told earlier, in Visual Mode once the value is selected, it will not come again in the suggestion list and hence there are no duplicate values to be selected. It is not an issue. So, please use the previous shared workaround sample for the Delimiter mode, as suggested.
Query2:” And 'enableDistinct' only works for local data source, in enterprise application, we usually refers to remote data source.”
We have tried to reproduce this issue, but we were unable to reproduce it. The enableDistinct property is working fine and duplication is also avoided in remote datasource.
Query3:” 'cancel' would be nice solution to avoid duplicated item”
The behavior of the “cancel” argument in select event is not what you expect. This cancel argument is used to cancel the remaining operations after the event triggered in our source. Therefore, it is not the correct scenario to use the “cancel” argument for cancelling the select event itself.
Please let us know if you have any further queries.
JZJason ZhuMarch 1, 2017 02:02 PM UTC
How to reproduce bug mentioned in preceding query 1?