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

GridView loading rows - tooks 5 to 10 sec with 2500 records

2 Answers 159 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Paweł
Top achievements
Rank 1
Paweł asked on 04 Jun 2013, 12:47 PM
Hi.
I'm not sure if im doing something wrong, but assuming this example:
http://demos.telerik.com/silverlight/#GridView/Performance
with 1000000 rows, 5 columns.
I need to load 2500 records with 8 to 10 columns and doing it like:

1st attempt to load data: using class product:

 using (SqlConnection conn = new SqlConnection(cString.c_String))
            {
                conn.Open();
SqlCommand cmd = new SqlCommand(sqlCommand, conn);
                rdr = cmd.ExecuteReader();
                while (rdr.Read())
{
-- Product p =new Product {.....};
myGrid.Add(p);
}

Second attempt:
                 SqlDataAdapter sd = new SqlDataAdapter(new SqlCommand(sqlCommand, conn));
                 DataTable dt = new DataTable();
                 sd.Fill(dt);
                dg.ItemsSource = dt.DefaultView;


Second is little bit faster i guess, but still tooks much time to load.
I have also tested only window loading time and it took ~1sec to load (only window, with listview with items from db)
Unfortunately with gridView it tooks 5 to 10 sec.

Question is:
Is there any way to (for example) load only first 50 records, and when i scroll down load more?
Or maybe there's example for gridView (WPF!) paging ?


Thanks for answer,
Adam.

2 Answers, 1 is accepted

Sort by
0
Paweł
Top achievements
Rank 1
answered on 04 Jun 2013, 01:36 PM
I find out that i can use DataPager and it works (unfortunately still took 5 to 10 sec)

 <telerik:RadGridView Grid.Row="0" Name="productsDataGrid" IsReadOnly="True" AutoGenerateColumns="False" ScrollViewer.HorizontalScrollBarVisibility="Auto" FilteringMode="FilterRow" telerik:StyleManager.Theme="Windows7" />

                <telerik:RadDataPager Grid.Row="1" PageSize="18" DisplayMode="FirstLastPreviousNext" x:Name="radDataPager" Source="{Binding Items, ElementName=productsDataGrid}" />
              
Is there any way to load ONLY first page when window loading? And second pages load after click next page or using filter?
0
Rossen Hristov
Telerik team
answered on 05 Jun 2013, 12:34 PM
Hello,

Currently you pull all the data into memory hence the slowness.

You can have real server-side paging if you use a technology such as LINQ-to-SQL or LINQ-to-Entities. The Skip and Take clauses that the pager generates on the respective IQueryable will be sent for execution directly to SQL server.


What you are currently doing is loading absolutely all data in-memory on the client and then paging this data in-memory. But you have fetched all the data from SQL server to memory so it is still slow. 

Please, see my reply in the other forum thread that you opened. They are duplicates.

Regards,
Rossen Hristov
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Paweł
Top achievements
Rank 1
Answers by
Paweł
Top achievements
Rank 1
Rossen Hristov
Telerik team
Share this question
or