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
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
@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
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:
@Jeff Breece
…
Compare your first few lines with the following. You had a couple typos :
AK
@Abed Khooli
Thank you, I must need new glasses!
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:
@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
@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