This project has moved and is read-only. For the latest updates, please go here.

Pulling specific range of items from a list

Jul 8, 2013 at 5:37 PM
Hi Everyone,

I'm trying to place 2 webparts on my page, both pulling from the same list (a news list) on one webpart I have a slider with news articles and the other just a list of news articles.

I want to place articles 1-4 from the list (the newest) to the first webpart, and the second articles 5-10. Is this possible to specify a range of articles to display on each webpart?

My next thought is on the second webpart to simply hide the first 4 unordered list items with jQuery or something.. might be the easier solution, but I'd like to hear if anyone knows of a query to use or any functionality that would allow specifying a range of list items to display?
Jul 8, 2013 at 6:45 PM
When you use GetListItems, it allows you to specify a ViewName. So maybe create the 2 views you need and go from there?

The first webpart would getlistitems from ViewFirstFour, the second WebPart would call from ViewFiveThroughTen.

Jul 9, 2013 at 4:10 AM
I would recommend staying away from views, if only because the odds are the someone will change them on you.

In your GetListItems call, simply specify how many items you want and in what sort order. In the code, use the first 4 in the first Web Part and the next 4 in the second Web Part.

Jul 9, 2013 at 6:59 PM
Thanks for the answers!

Hopefully it's not too much to ask more about your answer Marc, I see you state to "simply specify amount of items and what sort order". I can easily limit the first webpart to the latest 4 items, but the second webpart, how do I use a "next 4" items call? is there an easy option in the getlistitems call to specify "next 4 to 10 items"?

Jul 9, 2013 at 7:01 PM
Can you just do one call and use the first four and then the second four? In other words, use the single call to populate the area of the page you are thinking of as two Web Parts.