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

RadGrid Low Performance with Page size greater than 50

2 Answers 110 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Abhishek
Top achievements
Rank 1
Abhishek asked on 21 Jun 2011, 11:15 AM
Hi,
Why performance of rad grid goes down dramatically when it has to display more than 50 rows. Scroll bar gets stuck.
Please suggest solution to improve performance as this has been acritical issue for this project.

Also i had requirement of having "All" as PageSize ComboBox item to display all items at one time in grid. So i customized the "

PageSizeComboBox" as follows:

 Protected Sub grid_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles grid.ItemCreated

        If TypeOf (e.Item) Is GridPagerItem Then
            Dim pageBoundItem As GridPagerItem = DirectCast(e.Item, GridPagerItem)
            Dim PageSizeComboBox As RadComboBox = TryCast(pageBoundItem.FindControl("PageSizeComboBox"), RadComboBox)

            If PageSizeComboBox IsNot Nothing Then

        'Start **Page Size initialization
        Dim itemIndex As Integer = 0
        Dim minPageSize As Integer
        Dim maxPageSize As Integer
        Dim pageSizeStep As Integer
        Integer.TryParse(ConfigurationManager.AppSettings("MinPageSize").ToString(), minPageSize)
        Integer.TryParse(ConfigurationManager.AppSettings("MaxPageSize").ToString(), maxPageSize)
        Integer.TryParse(ConfigurationManager.AppSettings("PageSizeStep").ToString(), pageSizeStep)
        'End **Page Size initialization

        Dim ComboItem As RadComboBoxItem
        For iCount As Integer = minPageSize To maxPageSize Step pageSizeStep
            Dim newComboItem As RadComboBoxItem = PageSizeComboBox.Items.FindItemByValue(iCount)
            If newComboItem Is Nothing Then
                ComboItem = New RadComboBoxItem(iCount.ToString(), iCount.ToString())
                ComboItem.Attributes.Add("ownerTableViewId", gridClientId)
                PageSizeComboBox.Items.Insert(itemIndex, ComboItem)
            End If
            itemIndex += 1
        Next

        Dim newItem As RadComboBoxItem = PageSizeComboBox.Items.FindItemByValue(gridDataItemCount.ToString())
        If newItem Is Nothing Then
            ComboItem = New RadComboBoxItem("All", gridDataItemCount.ToString())
            ComboItem.Attributes.Add("ownerTableViewId", gridClientId)
            PageSizeComboBox.Items.Insert(PageSizeComboBox.Items.Count, ComboItem)
        Else
            newItem.Text = "All"
        End If

                AddHandler PageSizeComboBox.SelectedIndexChanged, AddressOf Me.PageSizeComboBox_SelectedIndexChanged
                PageSizeComboBox.AutoPostBack = True
            End If
          
        End If

    End Sub


Public Sub PageSizeComboBox_SelectedIndexChanged(ByVal sender As Object, ByVal e As RadComboBoxSelectedIndexChangedEventArgs)

        Dim intPageSize As Integer

        Integer.TryParse(e.Value, intPageSize)
        ViewState("intPageSize") = intPageSize.ToString()

        grid.PageSize = ViewState("intPageSize")
        grid.Rebind()

    End Sub



 Protected Sub grid_NeedDataSource(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles grid.NeedDataSource
        If ViewState("gridData") IsNot Nothing Then
            grid.VirtualItemCount = CType(ViewState("gridData"), DataTable).Rows.Count
            grid.DataSource = CType(ViewState("gridData"), DataTable)
        Else
            grid.VirtualItemCount = 0
            grid.DataSource = Nothing
        End If
    End Sub

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 21 Jun 2011, 02:54 PM
Hello Abhishek,

When you present large number of records at once you will see delays in the grid operations execution. If you have more than 100 records in a grid, it is recommended to turn on the build-in paging/custom paging of the grid. This will not only optimize the grid loading time but also will enrich the user experience.

Check out the following help article for more on optimizing the performance of the RadGrid.
Client/server grid performance optimizations.

Thanks,
Shinu.
0
Abhishek
Top achievements
Rank 1
answered on 22 Jun 2011, 10:22 AM
Hi Shinu,

I have already implemented custom paging. Also i have customized PageSize combo box to insert items like "10", "20", "30","40", "50" and "All". On  PageSize change event page gets refreshed that causes delay in response.

Why my page get reloaded on page size combo index change? I have all data in my ViewState.
Tags
Grid
Asked by
Abhishek
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Abhishek
Top achievements
Rank 1
Share this question
or