Completed
Last Updated: 10 Feb 2020 14:27 by ADMIN
Release R1 2020 SP1
ADMIN
Hristo
Created on: 02 Mar 2018 14:45
Category: Editors
Type: Feature Request
2
ADD. RadAutoCompleteBox - mode disabling the selection of already selected items
The new functionality should prevent duplicates to be added as tokens in the editor. An already selected item should not be visible in the popup as well. 

The attached 1148813-AutocompleteDuplicates.zip project features a possible custom solution. 
2 comments
ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 18 Dec 2019 12:34

Hello, Smisha,     

If you select an item from the autocomplete suggestions and then press the down key, the text of the already selected item is added in the editable part. This case can be handled by manipulating the code in the OnKeyDown method especially in the if statement for the Keys.Down.

            protected override void OnKeyDown(KeyEventArgs e)
            {
                if (e.KeyCode == Keys.Up)
                {
                    int newIndex = this.ListElement.SelectedIndex - 1;
                    while (newIndex > -1)
                    {
                        if (this.ListElement.Items[newIndex].Height == 0 || this.Text.Contains(this.ListElement.Items[newIndex].Text))
                        {
                            newIndex--;
                            continue;
                        }

                        if (newIndex > -1 && this.ListElement.Items[newIndex].Height > 0)
                        {
                            this.ListElement.SelectedIndex = newIndex;
                            return;
                        }
                    }

                    return;
                }

                if (e.KeyCode == Keys.Down)
                {
                    int newIndex = this.ListElement.SelectedIndex + 1 > this.ListElement.Items.Count ? 0 : this.ListElement.SelectedIndex + 1;
                    while (newIndex < this.ListElement.Items.Count)
                    {
                        if (this.ListElement.Items[newIndex].Height == 0 || this.Text.Contains(this.ListElement.Items[newIndex].Text))
                        {
                            newIndex++;
                            continue;
                        }

                        if (newIndex < this.ListElement.Items.Count && this.ListElement.Items[newIndex].Height > 0)
                        {
                            this.ListElement.SelectedIndex = newIndex;
                            return;
                        }
                    }

                    return;
                }

                base.OnKeyDown(e);
            }

As to the second case that was described, I was unable to observe the mentioned behavior after applying the above changes.

Note that this is a feature request and the provided sample project just demonstrates a possible approach for achieving the custom functionality and it may not cover all possible cases. Feel free to modify and extend it in a way which suits your requirements best. 

Please make sure that you cast your vote for it. The more votes an item gathers, the higher its priority becomes. 

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.
Smisha
Posted on: 18 Dec 2019 11:26

If we select an item then press key down it will show the already selected item.

Also select an item then type first letter and press key down when it comes to this item position even if list doesn't show the item, on enter autocomplete box shows the item.