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

How can we prevent Rad Autocomplete from accepting Duplicate entry?

9 Answers 472 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Ajith
Top achievements
Rank 1
Ajith asked on 16 Nov 2018, 06:40 AM
I have a AutoCompleteBox
My requirement is that I have to disable entering duplicate entries to the rad autocomplete box.
In my case I have a Languages autocomplete box but I am able to enter the item 'English' multiple times.
I want to ensure it is only entered once.
Question: Is there any-way so that if an entry is already there I can remove selected value?

9 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 19 Nov 2018, 11:32 AM
Hello, Ajith, 

Similar to Outlook, RadAutoCompleteBox allows entering duplicate entries. You can handle the TokenValidating event and specify that a certain token is not valid considering the already existing tokens in the RadAutoCompleteBox.Text. Then you can clear the text that is available in the TokenValidatingEventArgs. An alternative solution is not to show items that are already added as tokens and thus you will avoid duplicated entries. The following forum thread demonstrates a sample approach how you achieve this custom behavior: https://www.telerik.com/forums/remove-already-selected-item-from-autocomplexbox-auto-complete-items

Off topic, I have deleted the other thread that you have opened on the same topic.

I hope this information helps.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Yan Moura
Top achievements
Rank 1
Veteran
Iron
answered on 14 Jan 2020, 07:49 PM

Depends on your approach.

If you just don't want that a duplicated token be added it's quite easy: just keep a token array and check the new entry against the array in the EntryAdded event. If it already exists in the array ignore the new entry, otherwise add it to the array.

Now if you don't want that an existent token even show up in the list you may implement a control of your tokens by adding subsequent WHERE clauses to your query in order to ignore the specific tokens.

If you want the behavior above but you are not using a SQL query to populate your list - instead you're using a hard coded list - you can directly delete the used token from the list.

Just don't forget that in case of user delete one or more tokens, you have to remove it from your control array and put it back to the list by removing the respective WHERE clause (if using a SQL query) or inserting it back in your hard coded list.

Good luck!

 

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 17 Jan 2020, 08:49 AM

Hello, Yan,    

Thank you for sharing your idea wit he community.

However, I would like to note that the EntryAdded event is not relevant for RadAutoCompleteBox from the Telerik UI for WinForms suite since this forum thread is related to the WinForms autocomplete box. 

Note that we already have a feature request for introducing a mode which will control whether duplicated entries will be allowed or not. You can track its progress, subscribe for status changes and add your comments on the following link : https://feedback.telerik.com/winforms/1372559-add-radautocompletebox-mode-disabling-the-selection-of-already-selected-items 

It also contains a sample approach how to achieve such functionality in RadAutoCompleteBox.

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Ciupaz
Top achievements
Rank 2
Veteran
answered on 23 Jun 2020, 05:06 PM

Hello, any news about this topic?

I need to exclude already present items from the RadAutoCompleteBox.

 

L.

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 24 Jun 2020, 04:35 AM

Hello, Luigi,

As of R1 2020 SP1 RadAutoCompleteBox offers the AllowDuplicates property. It controls whether already selected items can be suggested.

 

Note that you can still add duplicated tokens in the editor if you type them manually. In order to avoid that you can subscribe to TokenValidating event and if the existing text in RadAutoCompleteBox contains the new text, set the IsValidToken property to false

private void RadAutoCompleteBox1_TokenValidating(object sender, TokenValidatingEventArgs e)
{
    if (this.radAutoCompleteBox1.Text.Contains(e.Text))
    {
        e.IsValidToken = false;
    }
}

I hope this information helps.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Ciupaz
Top achievements
Rank 2
Veteran
answered on 24 Jun 2020, 07:56 AM

I don't have the TokenValidating option in the HTML tags of my AutoCompleteBox.

How can I solve this? 

(PS: I'm using VB.NET as language). 

L.

 

 

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 24 Jun 2020, 08:29 AM

Hi, Luigi,

I would like to note that this forum is related to RadAutoCompleteBox from the Telerik UI for WinForms suite. However, it seems that you are not using the WinForms product.

Feel free to post any technical inquiries in the relevant forum: https://www.telerik.com/forums Thus, the appropriate community would gladly assist you.

Thank you for your understanding.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Ciupaz
Top achievements
Rank 2
Veteran
answered on 24 Jun 2020, 08:33 AM

Is it possible to update at version 2020 only the RadAutoCompleteBox component? 

 

0
Ciupaz
Top achievements
Rank 2
Veteran
answered on 24 Jun 2020, 08:38 AM

Ah, ok, sorry Dess. 
I'll try in the appropriate forum. 

L.

Tags
AutoCompleteBox
Asked by
Ajith
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Yan Moura
Top achievements
Rank 1
Veteran
Iron
Ciupaz
Top achievements
Rank 2
Veteran
Share this question
or