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

Setting DataLoadMode="Asynchronous" still blocks the UI thread

3 Answers 157 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tor
Top achievements
Rank 1
Tor asked on 23 Nov 2010, 04:26 PM
We have implemented a search as you type control using the RadGridView. Everytime the text changes we set the ItemsSource to a new source and when data is being loaded the text box is unresponsive. We have specified DataLoadMode="Asynchronous" but it doesn't help. Any ideas?

3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 29 Nov 2010, 08:57 AM
Hello,

 Why not use the grid filtering instead similar to our demo? When you reset ItemsSource the entire UI will be recreated from scratch which is expensive operation.  

Greetings,
Vlad
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
Tor
Top achievements
Rank 1
answered on 29 Nov 2010, 11:21 AM
Because that filtering does not work well with the NHibernate Linq provider. At the moment our code looks like this:

Private Sub UpdateQuery()
    If String.IsNullOrEmpty(SearchText) Then
        GridView.ItemsSource = CreateCollectionView(ItemsSource)
        Return
    End If
 
    Dim query = ItemsSource
    Dim dynamicQuery = String.Empty
    Dim exactMatchesQuery = String.Empty
    Dim excludeQuery = String.Empty
 
    For Each path In FilterPaths
        dynamicQuery &= path & ".StartsWith(""" & SearchText & """) Or "
        exactMatchesQuery &= path & ".Equals(""" & SearchText & """) Or "
        excludeQuery &= "(" & path & " <> NULL And " & path & ".Equals(""" & SearchText & """)) Or "
    Next
 
    dynamicQuery = dynamicQuery.Substring(0, dynamicQuery.Length - 4)
    exactMatchesQuery = exactMatchesQuery.Substring(0, exactMatchesQuery.Length - 4)
    excludeQuery = excludeQuery.Substring(0, excludeQuery.Length - 4)
 
    Dim fullQuery = "(" & dynamicQuery & ")" & " And Not (" & excludeQuery & ")"
    Dim exactMatches = ItemsSource.Where(exactMatchesQuery).ToIList()
    Dim collectionView = CreateCollectionView(query.Where(fullQuery))
 
    GridView.ItemsSource = collectionView
 
    Dispatcher.BeginInvoke(
        Sub()
            For Each match In exactMatches
                collectionView.Insert(0, match)
            Next
 
            collectionView.MoveCurrentToFirst()
        End Sub, DispatcherPriority.Input)
End Sub

Not optimal but it is the only working filtering against NHibernate's IQueryable.
0
Vlad
Telerik team
answered on 30 Nov 2010, 12:36 PM
Hi Tor,

 We've fixed this (DataLoadMode="Asynchronous" on initial load) and the fix will be part of our next internal build. I've added 2000 Telerik points to your account. 

All the best,
Vlad
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
Tags
GridView
Asked by
Tor
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Tor
Top achievements
Rank 1
Share this question
or