0

We are using SP2013 On-Premise Standard Edition. So Content Search WebPart is not available.

In a site collection there are 100+ subsites. Each subsite have a list with custom content type X. We need to show a view which have merged multiple list.

By using Content Query Web part I can show ALL the list items but it is not I need. I need to show the merged view for particular 3 of lists (3 lists out of 100+ lists).

How can I do it in SP2013?

JQuery and OOTB web part solution is preferred.

  • 1
    I don't think that there is a method to query across multiple lists in client side code. MSDN states "If you need to perform a cross-list query from client-side code, consider creating a list view on the server that performs the list aggregation." msdn.microsoft.com/en-us/library/ff798388.aspx – Bunzab Nov 9 '15 at 13:05
  • In the article CAML is used. Can I write CAML query at client side? I don't know c# – Mark L Nov 11 '15 at 15:28
  • Yes, very simply: var camlQuery = new SP.CamlQuery();. There are plenty of examples on the web. Search for JSOM CAML. – Bunzab Nov 12 '15 at 10:58
1

If you know the specific lists and sub-sites then this can be achieved using the GetListItems API. Basic design:

  • Issue 3 API calls; one to each of the lists you want retrieved. Ensure that you set the webUrl on each that corresponds to the URL of the subsite

  • use promises to catch the 3 responses and merge the data from the 3 lists into one single list

  • write the data to the page.

This post by Ben Tedder should get you going: Pull items from multiple lists in SharePoint

/Paul

  • "promises" is Promises Patterns? – Mark L Nov 11 '15 at 1:48
  • Can I also write the output in a table with filter and sorting option (just like OOTB sharepoint list view)? – Mark L Nov 11 '15 at 1:50
  • Yes, use promises to manage multiple Ajax data requests. Also: you can write the data out to any format you like. For a table that allows you to sort and filter, you should probably use a third party table widget. – Paul T. Nov 11 '15 at 11:48
0

With jQuery and JSOM you can achieve this

  1. Get the list items and store it in an array of JavaScript objects
  2. Find a suitable jQuery table plugin that supports Filtering, Sorting etc
  3. Bind the data to the plugin

Drawbacks of this approach is you need to load whole data in the client side. If you are dealing with 1000's of list items then it will have performance issues.

You can some what improve the performance using RowLimit but this require good amount of coding.

Edit - I have never tried this. Using SPD you can create a linked data source using multiple lists and drop it into a page.

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.