AsyncFilteringBehaviour

6 posts, 0 answers
  1. David
    David avatar
    4 posts
    Member since:
    Mar 2017

    Posted 30 Aug 2017 Link to this post

    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!

  2. David
    David avatar
    4 posts
    Member since:
    Mar 2017

    Posted 02 Sep 2017 in reply to David Link to this post

    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.
  3. Kalin
    Admin
    Kalin avatar
    1331 posts

    Posted 04 Sep 2017 Link to this post

    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.
  4. David
    David avatar
    4 posts
    Member since:
    Mar 2017

    Posted 04 Sep 2017 in reply to Kalin Link to this post

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

     

  5. David
    David avatar
    4 posts
    Member since:
    Mar 2017

    Posted 04 Sep 2017 in reply to David Link to this post

    The second 'Before' should obviously read 'After' whoops.
  6. Kalin
    Admin
    Kalin avatar
    1331 posts

    Posted 07 Sep 2017 Link to this post

    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.
Back to Top