This question is locked. New answers and comments are not allowed.
I was wondering if the Grid extension requires you to query all the records in order for paging to work? Our scenario is that we may have one million records coming back and we don't want all that to be queried for performance reasons, we just want the records for the Grid page we are on. If the Grid does require all the records in order for paging to work, is there a recommended approach to not make it do this? I appreciate any advice you can offer.
4 Answers, 1 is accepted
0
Alan Mosley
Top achievements
Rank 1
answered on 01 Oct 2011, 10:07 PM
When you page, the grid sends back the pagenumber and the pagesize, you can use this to get only the records you need, if you dont of cause it will bring back all records
0
20Below
Top achievements
Rank 1
answered on 02 Oct 2011, 01:50 AM
Thanks for the reply but I don't think that answers my question. I'll break down what I was asking:
1- User requests page
2- Controller runs logic to return model to View <-- It seems to me from the docs and your reply that I need to return ALL million+ records so the Grid knows how many pages to display in the pager. Yes/No?
3- View displays the Grid
When I run the example project, it looks like the Paging demo returns 800+ records to the view and results in a page size (uncompressed) of 100k+ (using Fiddler2).
1- User requests page
2- Controller runs logic to return model to View <-- It seems to me from the docs and your reply that I need to return ALL million+ records so the Grid knows how many pages to display in the pager. Yes/No?
3- View displays the Grid
When I run the example project, it looks like the Paging demo returns 800+ records to the view and results in a page size (uncompressed) of 100k+ (using Fiddler2).
0
Alan Mosley
Top achievements
Rank 1
answered on 02 Oct 2011, 04:13 AM
No, you can page the data from the source.The grid will give you the pagenumber and pagesize, when it calls the controller
Public Function GetOrders(page As Integer, size As Integer) As ReadOnlyCollection(Of bo.Invoice)You can then usae it to limit your query, somthing like
db.Invoices _
Where(Function(w) w.FranchiseeId.Equals(Me.FranchiseeId)) _snip long code OrderByDescending(Function(o) o.InvoiceId).Skip((page - 1) * size).Take(size).ToList())As you can see i am returning only the resultts to display
0
James
Top achievements
Rank 1
answered on 24 Apr 2012, 05:46 AM
Hi,
I'm running an ASP.Net MVC3 Website and one of my pages displays a list of people using Telerik Grid. I'm working with a large number records in my database, so I can't afford to query all of them every time. I'm currently using the ajax binding method specified here: http://demos.telerik.com/aspnet-mvc/razor/grid/ajaxbinding
Requirements:
- server should only query database for items on a single page
- server/clientside load should be minimized as much as possible
Questions:
1. I can't get the page to show up even after setting the total number of records using
Is this because I'm not using custom ajax binding? I haven't been successful in applying custom binding shown here http://demos.telerik.com/aspnet-mvc/razor/grid/custombinding , so I was trying to see if I can achieve these results using the normal way of ajax binding.
2. Can you show me where in the code to specify a query that only retrieves the items for the specific page?
[Updated]
I solved the issue. Seems like the two things that were crucial were:
- EnableCustomBinding (in both Controller Action and View)
- set the total number of items using the paging.Total code above
After setting these two, all I had to do was make a query to the database for a limited number of items. In my case, I was using Petapoco, so I used the Petapoco.Page<>() method.
Thanks,
James
I'm running an ASP.Net MVC3 Website and one of my pages displays a list of people using Telerik Grid. I'm working with a large number records in my database, so I can't afford to query all of them every time. I'm currently using the ajax binding method specified here: http://demos.telerik.com/aspnet-mvc/razor/grid/ajaxbinding
Requirements:
- server should only query database for items on a single page
- server/clientside load should be minimized as much as possible
Questions:
1. I can't get the page to show up even after setting the total number of records using
.Pageable(paging => paging.Total((int)ViewData["total"]))
Is this because I'm not using custom ajax binding? I haven't been successful in applying custom binding shown here http://demos.telerik.com/aspnet-mvc/razor/grid/custombinding , so I was trying to see if I can achieve these results using the normal way of ajax binding.
2. Can you show me where in the code to specify a query that only retrieves the items for the specific page?
[Updated]
I solved the issue. Seems like the two things that were crucial were:
- EnableCustomBinding (in both Controller Action and View)
- set the total number of items using the paging.Total code above
After setting these two, all I had to do was make a query to the database for a limited number of items. In my case, I was using Petapoco, so I used the Petapoco.Page<>() method.
Thanks,
James