Home > Data Form, Libraries, Lists, SharePoint Designer 2010 > How To Display Documents From Different Libraries Using DataView

How To Display Documents From Different Libraries Using DataView

The content query webpart (CQWP) is usually used for content rollup across a site collection and it is very powerful, but it is not easy to customize and style. Using a dataform webpart with some tweaking can do the trick (and you have to use SharePoint Designer 2010 to do that).
A blog article titled SPDataSource and Rollups with the Data View is the starting point here. You basically edit the data source in source mode to enable cross list fetching of items and specify what kind of list you want to include. Lists (and libraries) have something called ServerTemplate id or value and you can find these here. A document library has value = 101.
So, here’s how we start: add a web part page and insert an empty data view (insert – data view – empty data view). Click to add source and select a document library. In this case, I selected Shared Documents in a team site (and I also have a blank site under it with another document library called blankdocs). Then, inserted the datasource selected fields as multiple item view. I added a filter (from options) to include items with title that contains the word “Policy” and also selected which fields to show and items per page (all items).
Now, switch to source mode and find the datasource tag (if you had the view selected, you get the corresponding source highlighted). You need to change DataSourceMode=”List”  to DataSourceMode=”CrossList” and in the selectcommand add <Webs Scope="Recursive"></Webs><Lists ServerTemplate="101"></Lists> inside the tags. Notice that the < and > are replaced with their own literals. This should get the items, but how do you link to the documents themselves? Well, select one of the titles, right-click and select Format as .. hyperlink. Keep the Text To Display as is and in the address, put {concat(‘/’,substring-after(@FileRef,’#'))} and you are done. You can clean up other fields or format them differently or even do conditional formatting. Documents come from any library in the site collection meeting the criteria. You cold do the same for other types of lists (remember to use the correct ServerTemplate value and adjust links.

SPDataSource and Rollups with the Data View

Categories: Data Form, Libraries, Lists, SharePoint Designer 2010 Tags: CrossList, dataview rollup, display documents from different libraries
  1. Michael Friedenberg
    July 15th, 2011 at 18:43 | #1

    I followed your instructions exactly using a document library. I changed the datsource mode to CrossList and added to the selectcommand in the proper place. But it doesn’t return any data.

    Is there a step I’m missing or something else I should be looking at?

    Thanks

    Michael

  2. Abed Khooli
    July 16th, 2011 at 10:07 | #2

    @Michael Friedenberg
    If you see strange column names and no data in cells, click the data source hyperlink (Shared Documents in the above example), click on Fields and pick a few familiar ones from the right side column. I noticed this on SP1.
    AK

  3. August 16th, 2011 at 15:52 | #3

    Abed,

    Thanks for posting this however I am having an issue with the scope being limited to the current site’s document library. I know I am overlooking something obvious I am not sure what though.

    I read the post “SPDataSource and Rollups with the Data View” at the Microsoft SPD Team Blog you referenced along with an example by Laura Rogers. I have a feeling it is the ParameterKey & DefaultValue that were generated by SPD in the SelectParameters, UpdateParameters, InsertParameters & DeleteParameters. When I comment that block out I get an error. However when I leave it in I am limited to the current site.

    Thank you (X100) for any guidance you can provide.

    Code example below:


    /Webs>1” UseInternalName=”True” UseServerDataFormat=”True” Scope=”RecursiveAll” ID=”dataformwebpart1″>









  4. Abed Khooli
    August 16th, 2011 at 19:59 | #4

    @Jeff Breece
    Compare your first few lines with the following. You had a couple typos :

    AK

  5. August 18th, 2011 at 14:04 | #5

    @Abed Khooli
    Thank you, I must need new glasses!

  6. Shiri
    August 23rd, 2011 at 12:36 | #6

    Hi,

    The SPDataSource I created keep showing only list and not document libraries.
    Can anyone have a look and tell me what I’m doing wrong?
    I appreciate your help!

    Here is my code:

  7. Abed Khooli
    August 23rd, 2011 at 16:51 | #7

    @Shiri
    You are probably trying to insert datasource from the ribbon. Instead, click inside the dataform web part on the link that reads: click here to select a datasource. Pick one of the libraries and follow the details above.
    AK

  8. Shiri
    August 24th, 2011 at 11:32 | #8

    @Abed Khooli

    Thanks Abed, the selectcommand got lost in my question but that was what I used. Anyway, after much research of me and my colouges we found out we used a worng syntaxin in the selectcommand. We used , but the right syntax is .

    Thanks alot :-)
    Shiri

  1. July 17th, 2011 at 15:36 | #1
    SharePoint 2010 Help » Linked Data Source In A Records Center