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

Asynchronous population

3 Answers 291 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tommy
Top achievements
Rank 1
Tommy asked on 16 Jul 2008, 09:39 AM
Hi,

My issue is that our customers can have a lot of records for one GridView. For example one, whoes data I'm currently using for testing has rounded 17'000 records.

As our database is not the best (no SQL) it has to be processed while being read and the put into a DataTable to pass it over the the radGrid. Without asynchronous population the loading takes about 15 seconds. Is not bad but still to slow. 

I load the first 200 entries into the grid and then use a BackgroundWorker to process the Rest. My problem is, I want to pass the newest records over to the Radhrig so that it gets constantly updated untill everything is read. The problem is there that when i start scrolling the hole think crashes.

Is there a way to set the new DataSource even when I am scrolling or using the Filter? The client should be able to work normally with the grid while the data gets added.

3 Answers, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 18 Jul 2008, 08:35 AM
Hi Tommy,

The RadGridView control like the standard WinForms controls and the rest of our controls is not designed to work in a asynchronous mode. Bringing the grid in this mode would lead to unpredicted behaviour.
You can setup RadGridView after the loading of data in BackgroundWorker is completed.

A possible solution would be to make paging of your data and load small piece of it.
Another solution is to use VirtualMode of RadGridView, but in this scenario all sorting/grouping/filtering operations are not processed.

If you have additional questions, please contact us.

Regards,
Julian Benkov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Henrik
Top achievements
Rank 1
answered on 15 Aug 2008, 06:31 AM
Hi Tommy,

We had the same issue and while multi-threading when we fetch data over async WCF. If the grid changes due to user interaction while you bind in a different thread it crashes the application.

We worked around the issue by making sure the binding always occur in the main thread using a custom RadGrid and a timer that starts when you launch the thread and stops once binded.

Public Class myRadGrid

    Inherits Telerik.WinControls.UI.RadGridView

    Friend WithEvents evoTimer As New System.Windows.Forms.Timer

    Private IsBound As Boolean

   ' Fix themes Issues due to inheritance

    Public Overrides Property ThemeClassName() As String

        Get

            Return "Telerik.WinControls.UI.RadGridView"

        End Get

        Set(ByVal value As String)

        End Set

    End Property

    Private Sub evoTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles evoTimer.Tick

    If IsBound = True Then

        IsBound =

False

        Me.DataSource = _ds

     End If

    Me.evoTimer.Enabled = False

    End If

End Sub

 

Public Sub evoBeginBindAsync()

    Me.evoTimer.Interval = 150

    Me.evoTimer.Enabled = True

    Me.IsBound = False

End Sub

 

Private _ds As DataSet

Public Sub evoBindAsync(ByVal ds As DataSet)

    _ds = ds

    IsBound =

True

End Sub

---------------------------------------------------------------

THEN ON THE FORM

Private Sub LoadGrid()

    .......

    EvoGrid.evoBeginBindAsync()

    ' Start the thread here
    MyNewThread(...)


End Sub

' New thread

Private Sub MyNewThread.......()

    .......

    EvoGrid.evoBindAsync(DATASET RETURNED)

    ........

End Sub

That worked for us. Though it would be nice if Telerik would come with a funcion like BindAsync(datasource) that would not be crashing. Until then...

Hope this help

Cheers

0
Henrik
Top achievements
Rank 1
answered on 16 Aug 2008, 03:58 AM
We also had a stable result without the timer by replcing it with an BeginInvoke method

Private Sub InvokedBinding(ByVal sender As Object, ByVal e As System.EventArgs)

Me.DataSource = sender

End Sub

Public Sub evoBindAsync(ByVal ds As DataSet)

    BeginInvoke(

New System.EventHandler(AddressOf InvokedBinding), ds)

End Sub

Cheers

Tags
GridView
Asked by
Tommy
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Henrik
Top achievements
Rank 1
Share this question
or