6 Answers, 1 is accepted
You can retrieve as many records as you need by using the .PageSize method:
Thank you for the reply!
PageSize(20) only shows 20 rows in a page but the page is still retrieving all 3000 rows to the client or at least it looks as it is.
My question is how to improve the speed of the grid? If we have 1 row its instant if we have 3000 it takes up to 2 minutes to load.
If we filter it to show some rows based on criteria it is very fast also.
Is there an option to retrieve only the rows for the page that is showing. Say we have 20 rows per page and we click on page 5 can we only retrieve rows from 80-100? We still need to keep our filters working..
Maybe the slow bit is .ToDataSourceResult(request) ..
Here is the whole view:
By default the DataSource retrieve 10 records if PageSize is not set. This means that you receive 10 records on the client and the grid shows 10 records. The performance issue might be caused by something else. You can easily check how many records really come from the data source by inspecting the response via your browser web developer tool as shown on this short screen cast I captured: http://screencast.com/t/RHTO7xbwgv or via Fiddler.
The dataSource configuration provided by Derek was missing the PageSize() method, once you add it, the grid will request the desired amount and only those number of records will be returned when using the ToDataSourceResult() extension method in the controller:
.DataSource(dataSource => dataSource .Ajax() .Read(read => read.Action("Orders_Read", "Grid")) .PageSize(20) )