Hi All,
I am trying to implement an AutoCompleteBox dynamically in C#, everything loads great but I have ~15,000 records to filter and it takes a few seconds to load. I have read that this can be improved with AsyncFilteringBehaviour but only ever see reference to how this is set in XAML.
I have tried to simply set the following, but am obviously missing something because it doesn't filter at all when I do this:
myAutoCompleteBox.FilteringBehavior = new AsyncFilteringBehavior();
Any help would be appreciated!
5 Answers, 1 is accepted
We are not aware of issues with the AsyncFilteringBehavior of RadAutoCompleteBox .Can you please provide sample code/project that reproduces the issue, so we can check it on our side? If can you provide part of the ItemsSource that wold be helpful.
I'm looking forward to hearing from you.
Regards,
Kalin
Progress Telerik
I tried to pull the code out of my project to show you and in the process stumbled across a 'solution'. I don't pretend to understand how it made a difference. I was obtaining a set of Key Value pairs from a SQL Database and iterating through to assign to an ObservableCollection, then I was setting the ItemsSource of the AutoCompleteBox to this ObservableCollection. It was very slow and the Async filtering wouldn't work.
In an effort to understand I created from scratch but put the function to fill the observable collection in it's own class instead of having it in the same function that created the AutoCompleteBox. This worked and allows me to use the Async filtering. I used the exact same code to fill the collection. There is obviously something I am miss understanding, but it working so I am happy.
Before:
RadAutoCompleteBox acb = new RadAutoCompleteBox();
// Setting name and formatting
// Calling to SQL and filling Dataset
ObservableCollection<KeyValuePair> ocKeyValue = new ObservableCollection<KeyValuePair>();
foreach(DataRow dr in ds.Tables["dtDropdown"].Rows)
{
KeyValuePair kvp = new KeyValuePair((string)dr.ItemArray[0].ToString(), (string)dr.ItemArray[1].ToString());
ocKeyValue.Add(kvp);
}
acb.ItemsSource = ocKeyValue;
acb.DisplayMemberPath = "Value";
acb.FilteringBehavior = new AsyncFilteringBehavior();
Before:
RadAutoCompleteBox acb = new RadAutoCompleteBox();
// Setting name and formatting
// Calling to SQL and filling Dataset
acb.ItemsSource = KVPCollection.DataCreator(dataTable);
acb.DisplayMemberPath = "Value";
acb.FilteringBehavior = new AsyncFilteringBehavior();
The way assigning the collection shouldn't make any difference, however I'm glad that is working as expected now. If you manage to isolate the scenario - you could send it to us and will be glad to investigate and see what is the exact problem.
If you have any other questions or concerns, please do not hesitate to contact us.
Regards,
Kalin
Progress Telerik