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

RadGrid Grouping very slow

1 Answer 165 Views
Grid
This is a migrated thread and some comments may be shown as answers.
<><
Top achievements
Rank 1
<>< asked on 27 May 2011, 08:16 PM
Hi,

Just started using your RadGrid for ASP.net here at work and have a table with about 500,000 rows that I am testing with.  Sorting/Paging/Filtering all works fine and I am able to build a custom linq query to only return the rows i need to be displayed...but, I'm not having any luck doing that with grouping as I need to return the entire resultset for radgrid to group correctly.

As the rows increase in the database table, so does the time it takes for the page to load when grouped or when performing any type of grouping, i'm using the following code for testing, and currenly have PageSize set to 10, as per the default.

Protected Sub RadGrid1_NeedDataSource(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
    Dim db As New TrackerDataContext
    db.Log = New System.Diagnostics.DebuggerWriter
    Dim query = From p In db.posts
                Where p.parentid = 0
                Select p
    If String.IsNullOrWhiteSpace(RadGrid1.MasterTableView.FilterExpression) = False Then
        query = query.Where(RadGrid1.MasterTableView.FilterExpression)
    End If
    For Each exp As GridSortExpression In RadGrid1.MasterTableView.SortExpressions
        query = query.OrderBy(String.Format("{0} {1}", exp.FieldName, exp.SortOrder.ToString))
    Next
    Dim start As Integer = RadGrid1.CurrentPageIndex * RadGrid1.PageSize
    Dim max As Integer = RadGrid1.PageSize
    RadGrid1.AllowCustomPaging = True
    'we always need count
    RadGrid1.VirtualItemCount = query.Count
    If isGrouping Or RadGrid1.MasterTableView.GroupByExpressions.Count > 0 Then
        start = 0
        max = RadGrid1.VirtualItemCount
        RadGrid1.AllowCustomPaging = False
    End If
    RadGrid1.DataSource = query.Skip(start).Take(max)
End Sub

Private isGrouping As Boolean = False
Protected Sub RadGrid1_GroupsChanging(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridGroupsChangingEventArgs) Handles RadGrid1.GroupsChanging
    isGrouping = True
    If e.Action = GridGroupsChangingAction.Ungroup AndAlso RadGrid1.MasterTableView.GroupByExpressions.Count = 1 Then
        isGrouping = False
    End If
End Sub

Is there any way to improve the performance?

Take Care

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 30 May 2011, 09:26 AM
Hello,

Useful tips on how to optimize the RadGrid performance using different techniques can be found in the online resources linked below:
http://www.telerik.com/help/aspnet-ajax/gridoverview.html (Chapter "Performance tips and tricks")
http://www.telerik.com/products/aspnet-ajax/resources/top-performance.aspx
http://www.telerik.com/support/aspnet-ajax.aspx (Section "Performance")

I hope this helps.

All the best,
Pavlina
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
<><
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or