In a recent post, I pointed out a way to roll up calendar entries using the Data View Web Part (DVWP). That approach works if you have a fixed set of calendars for which you’d like to display the roll-up. But what if you’d like the roll-up to be dynamic, i.e., have it display events for any new calendars that are created below a certain place in your site hierarchy?
Well, the way to do this is still using the trusty old DVWP (how could we live without it?!?!?!). There are several DataSourceModes that are available in the DVWP that aren’t exposed in the SharePoint Designer interface. (ListofLists, Webs, and CrossList modes. ListsofLists and Webs modes show the collection of lists and the collection of subsites for a given site.) The mode that we need here is CrossList, which allows us to display items across lists below a certain point in the site hierarchy.
Here are the basic steps:
- Set up your DVWP so that it has the display that you want for all of the lists, but do it the way you normally would for a single list. (i.e., pick one of your lists and make everything pretty for it alone.)
- Now, if you aren’t already there, switch to code view, and in the code for your DVWP find the DataSourceMode property and change it from List to CrossList.
- Right after that property, you’ll see the SelectCommand property. This is the code that tells the DVWP what query to use for the SPDataSource. Add <Webs Scope=’Recursive’></Webs> immediately after the opening quote, and leave the rest of the SelectCommand as it is.
- Immediately after this section, you will see values for <SelectParameters>, <DeleteParameters>, <UpdateParameters>, and <InsertParameters>. You can delete all of these, as they are not relevant to the CrossList mode.
- Down a little further, you’ll see the <ParameterBindings> section. Make sure that the line <ParameterBinding Name=”WebURL” Location=”None” DefaultValue=”/sitename/subsitename/”/> reflects the “root” from which you’d like the rollup to work. (i.e., the DVWP will shown all items from this site and below — That’s what the Recursive scope you put into the SelectCommand does.)
- Lastly, go a little further down and make sure that the path in the line <xsl:param name=”WebURL”>/sitename/subsitename/</xsl:param> matches the one above.
- You can also remove any references to ListIDs, as they aren’t relevant.
If you’ve done everything right, you should see items returned by the DVWP that come from all of the like-structured lists below the site you’ve indicated. You can continue to make formatting changes in the XSL, but to me it seems easier to get it at least close to right before you switch to CrossList mode.
NOTE: I posted an update to this post on September 21, 2008. You should read that followup in conjunction with this post.
If you found this post helpful, please consider visiting one or more of the advertisers on the page. Writing good, in depth blog posts takes time, and advertising revenue - though by no means large - helps to offset the effort.