2

I want to have a web part which displays data from a Sharepoint list. I have tried to do this using the Content Query Web Part by displaying the results in descending order using the 'Created' column, so it shows the most recent items. I will be limiting this to 5 items.

However, I do not want the web part to show the five most recent items. Instead, want it to show items 6,7,8,9 and 10 from the list. Can someone explain how it would be possible to do this?

  • You can modify the elements to show by using javascript. For example, you can set up your CQWP to get the top 10 and hide the first 5 elements. – Daniel 976034 Jan 7 '16 at 12:28
  • Cheers Dan - that seems the best route to go down. Any tips on writing that bit of code? – jahlive Jan 7 '16 at 16:39
  • it depends on the code your template. I cannot help you if you don't provide the html. – Daniel 976034 Jan 10 '16 at 11:06
1

Make use of the Sharepoint REST api, where you need to make a http call with a query which is very easy to filter and sort the results. It should look something like this

/_api/web/lists/getByTitle('List_Name')/items $select=Col1,Col2&$filter=Created ge '5'&$orderby=Created desc&$top=5"

Replace the values in bold with your desired ones if you wish to use this method. I believe this will retrieve the data that you are looking for.

You must use javascript to make the http call and to use the retrieved data. I suggest you to check on google about Get sharepoint list data using angular.

-1

If you want to display items with an ID (or any other numeric field for that matter) within a given range, you can use the "Additional Filters" section of the Content Query Web Part to add that constraint:

CQWP filters

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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