Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I was wondering what people think the best way is to jump to a specific page within a sharepoint list, taking into account performance considerations.

eg:

1) List with 1000 items in it

2) Each page contains 10 items

3) Show up to 10 pages at a time.

4) User can jump to any page by typing in the page number (i.e. No Next / Previous)

Here is my thinking

1) Using itemsPerPage = 10, pageNumber = ?

Use 2 Queries and a loop to find the ListItemCollectionPosition and Combine with RowLimit.

i.e.

a) Get the start position

ListItemCollectionPosition positionToStart = null;

for (int i = itemsPerPage ; i < itemsPerPage * pageNumber; i + itemsPerPage)
{ 
   SPQuery.RowLimit = itemsPerPage  ;
   var spItems = SPList.GetItems(SPQuery).Items;
   if (spItems.ListItemCollectionPosition != null)
   { 
       positionToStart = spItems.ListItemCollectionPosition;
   }
}

b) Get The Results

SPQuery.RowLimit = itemsPerPage;
SPQuery.ListItemCollectionPosition = positionToStart 
return SPList.GetItems(SPQuery).Items;

Any help would be great!

share|improve this question
    
Is there a reason not to use the built in pagination on the list? Is this a custom page that needs something different? –  spevilgenius Nov 1 '11 at 10:38
    
Yes, this is a custom page that requires <Previous> 1, 2, 3 ,4 <Next> –  Lukie Nov 1 '11 at 21:04
    
How are you displaying the list items? Are you using a gridview or something? A regular list view can be paged so I am just trying to figure out what you are doing. –  spevilgenius Nov 2 '11 at 11:15
add comment

2 Answers 2

Another way that should be considered is the "javascript way" :)

ListData.svc supports easily pagination by adding a "top" and "skip" parameter. I found more info here

You could combine the ajax call with Knockout.js or XSLT transformation to obtain the desired UI.

Cheers!

share|improve this answer
1  
I have had a lot of success with this method. I've had Kendo UI grid controls getting data from 4 lists to build a mashup with over 3000 items in the grid (client paging) all from a dev server with 2GB RAM and a dual core processor and it took 3 seconds to get all the data. The UI responded quickly and it took about an hour to set up. –  Robert Kaucher Jun 15 '13 at 3:52
add comment

As far as I know the only way you can do it is to retrieve (page number * 10) items and then only show the last 10. The ListItemCollectionPosition mechanism is completely built on the next / previous metaphor and will not work otherwise.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.