Hi,
Is there any way to allow RadAutoCompleteBox auto suggestion item to select only unique items. For example, RadAutoCompleteBox has item A, item B and item C. I don't want user to choose Item A two times. Would like to remove previously selected item from auto suggestion list. For example Item A is already in the RadAutoCompleteBox.Items collection, want to show only item B and C in auto complete suggestion box. If not possible to do that, want to cancel the selection if existing item is selected again. Is it possible to do that?
4 Answers, 1 is accepted
0
Accepted
Hello Amos,
Thank you for writing.
You can achieve your requirement by setting the RadAutoCompleteBox.ListElement.DataLayer.DataView.Filter predicate. Thus, you can control whether a specific RadListDataItem will be displayed in the popup or not. Here is a sample implementation:
I hope this information helps. Should you have further questions, I would be glad to help.
Regards,
Dess
Telerik
Thank you for writing.
You can achieve your requirement by setting the RadAutoCompleteBox.ListElement.DataLayer.DataView.Filter predicate. Thus, you can control whether a specific RadListDataItem will be displayed in the popup or not. Here is a sample implementation:
public Form1(){ InitializeComponent(); List<Item> items = new List<Item>(); items.Add(new Item(1,"A1")); items.Add(new Item(2,"A2")); items.Add(new Item(3,"A3")); this.radAutoCompleteBox1.AutoCompleteDataSource = items; this.radAutoCompleteBox1.AutoCompleteDisplayMember = "Name"; this.radAutoCompleteBox1.AutoCompleteValueMember = "Id"; this.radAutoCompleteBox1.ListElement.DataLayer.DataView.Filter = FilterItem;}private bool FilterItem(RadListDataItem item){ string[] tokens = this.radAutoCompleteBox1.Text.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (tokens.Length > 0) { foreach (string token in tokens) { if (item.Text.StartsWith(token)) { return false; } } } return true;}public class Item{ public int Id { get; set; } public string Name { get; set; } public Item(int id, string name) { this.Id = id; this.Name = name; }}I hope this information helps. Should you have further questions, I would be glad to help.
Dess
Telerik
0
Amos
Top achievements
Rank 1
answered on 01 Jul 2015, 01:26 AM
Thanks you. It helps me.
Regards
0
Smisha
Top achievements
Rank 1
answered on 04 Jan 2020, 09:34 AM
It's not working for me when i set autocompletemode to append or suggestappend
0
Hello, Smisha,
I have attached my sample project for your reference. Please give it a try and see how it works on your end with the latest version of the Telerik UI for WinForms suite.
I hope this information helps.
I have attached my sample project for your reference. Please give it a try and see how it works on your end with the latest version of the Telerik UI for WinForms suite.
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.
