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

Grid issue for large number of records

3 Answers 158 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jagadeeswararao
Top achievements
Rank 1
Jagadeeswararao asked on 27 May 2014, 10:25 AM
I have grid contains more than 6k records, when i'm selecting pagesize form "ALL" to 10 getting error page (IE Diagnosis error page).
tested it for low number of records which is working fine.

Can plz someone help me on this issue.

Thanks,
Jagadeesh

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 27 May 2014, 10:50 AM
Hi Jagadeesh,

The browser is your limitation. It's not good practice to show more than a useful amount of data on the screen at once. Its better not have All option. If you want to search through the data quickly, you could add search capabilities that filter the results. You can have the grid with Virtual scrolling and paging or Custom Paging etc. Please take a look at this article for more information: Client/server grid performance optimizations.

Thanks,
Princy
0
Jagadeeswararao
Top achievements
Rank 1
answered on 27 May 2014, 11:34 AM
Hi Princy,
  Thanks for responding early.. Of course you are right. but i have requirement to show all the records when selecting all. I'm able to show all the records at time but not moving back to page size 10 or 50, Any other solution can i have.
(I have used tabstrip too in my page.)

Thanks,
Jagadeesh
0
Princy
Top achievements
Rank 2
answered on 28 May 2014, 05:57 AM
Hi Jagadeesh,

As mentioned above when you have the entire grid to display so many records at a time, it will cause performance issue. Below is a sample code snippet I tried for setting PageSize, please have a look.

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="true" OnNeedDataSource="RadGrid1_NeedDataSource" OnItemCreated="RadGrid1_ItemCreated">
    <PagerStyle AlwaysVisible="true" />
</telerik:RadGrid>

C#:
protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
    DataTable dt = new DataTable();
    dt.Columns.Add(new DataColumn("Item #", typeof(int)));
    dt.Columns.Add(new DataColumn("Contract Number", typeof(string)));
    dt.Columns.Add(new DataColumn("Customer Name", typeof(string)));
 
 
    int i;
    for (i = 0; i < 6000; i++)
    {
        DataRow dr = dt.NewRow();
        dr["Item #"] = i;
        dr["Customer Name"] = "CustomerName"+i;
        dr["Contract Number"] = "Contract Number" + i;          
        dt.Rows.Add(dr);
    }    
    RadGrid1.DataSource = dt;
        
}
protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridPagerItem)
    {
        var dropDown = (RadComboBox)e.Item.FindControl("PageSizeComboBox");
        var totalCount = ((GridPagerItem)e.Item).Paging.DataSourceCount;
        var sizes = new Dictionary<string, string>() {
        {"10", "10"},
        {"20", "20"},
        {"50", "50"}
    };
        if (totalCount > 100)
        {
            sizes.Add("100", "100");
        }
        if (totalCount > 200)
        {
            sizes.Add("200", "200");
        }
        sizes.Add("All", totalCount.ToString());
 
        dropDown.Items.Clear();
        foreach (var size in sizes)
        {
            var cboItem = new RadComboBoxItem() { Text = size.Key, Value = size.Value };
            cboItem.Attributes.Add("ownerTableViewId", e.Item.OwnerTableView.ClientID);
            dropDown.Items.Add(cboItem);
        }
        dropDown.FindItemByValue(e.Item.OwnerTableView.PageSize.ToString()).Selected = true;
    }
}

Thanks,
Princy
Tags
Grid
Asked by
Jagadeeswararao
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Jagadeeswararao
Top achievements
Rank 1
Share this question
or