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

Property 'enableDistinct' and 'select event' in ejAutocomplete with web api adaptor and mutiSelectionMode

Hi,

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?


Thanks,
Jim 




5 Replies

AP Arun Palaniyandi Syncfusion Team February 24, 2017 07:31 AM UTC

Hi Jim,   
   
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 as VisualMode. 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.   
   
   
If the provided sample does not meet your requirement, please give us with more information that will help us to provide the solution.    
   
Regards,   
Arun P.   



JZ Jason Zhu February 28, 2017 08:11 PM UTC

 Arun P,

Thanks for help.  

For the first link http://jsplayground.syncfusion.com/qjef4fga   , it  has bug if I  change  mode as : ej.MultiSelectMode.VisualMode.
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.


Jim 





AP Arun Palaniyandi Syncfusion Team March 1, 2017 11:10 AM UTC

Hi Jim,   
   
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.   
   
Regards,   
Arun P.   



JZ Jason Zhu March 1, 2017 02:02 PM UTC

How to reproduce bug mentioned in preceding query 1?
1)In  http://jsplayground.syncfusion.com/qjef4fga , Change  multiSelectionMode as VisualMode.
2)Run script
3)Type 'a' in text box,  use mouse to select 'Arizona' 
4)Type any character again, for example 'a', it will immediately show 'Arizona a' in text box. It is supposed to only show  what you entered (here it is 'a').   That is bug.



Thanks,
Jim





AP Arun Palaniyandi Syncfusion Team March 2, 2017 12:51 PM UTC

Hi Jim,    
    
A support incident to track the status of this defect has been created under your account. Please log on to our support website to check for further updates. 
 
Please let us know if you have any queries. 
 
Regards, 
Arun P. 


Loader.
Up arrow icon