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

AsyncFilteringBehaviour

5 Answers 210 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 30 Aug 2017, 11:11 PM

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

Sort by
0
David
Top achievements
Rank 1
answered on 02 Sep 2017, 08:03 PM
So after playing around with it a little bit it appears the filtering behaviour is being set. The problem is that the AsyncFilteringBehavior doesn't return anything. If I toggle this between Async and a custom filter the custom filter works but is slow, the Async filter just does nothing at all.
0
Kalin
Telerik team
answered on 04 Sep 2017, 08:43 AM
Hi David,

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
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
David
Top achievements
Rank 1
answered on 04 Sep 2017, 01:23 PM

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();

 

0
David
Top achievements
Rank 1
answered on 04 Sep 2017, 01:24 PM
The second 'Before' should obviously read 'After' whoops.
0
Kalin
Telerik team
answered on 07 Sep 2017, 12:27 PM
Hi David,

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
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
AutoCompleteBox
Asked by
David
Top achievements
Rank 1
Answers by
David
Top achievements
Rank 1
Kalin
Telerik team
Share this question
or