Building a Rollup List in SharePoint


Building a Rollup List
in SharePoint

By

Gatika Patel
Kiefer Consulting


 


INTRODUCTION

A
frequent challenge for me in SharePoint is finding a way to combine multiple
SharePoint lists at the root level site and then performing different operations
on that “rolled up” list. Third-party web parts sometimes help, but budget
constraints often prevent us from buying our way out of this problem. After some
online research, I found an easy way to write my own code to roll up lists.

To
display items across lists, you can use Data View Web Part (DVWP). The DVWP has
some DataSourceModes you may not be aware of, including
Webs, ListofLists, and
CrossList
. For example, for a given site, the
Webs mode shows the collection of
subsites, and the ListofLists mode
shows the collection of lists. In my example below, I use the
CrossList mode to combine items from
multiple lists across the site hierarchy. This solution works in both SharePoint
2007 and SharePoint 2010.


STEPS

Below are the basic steps
necessary to use the CrossList mode:


1.      
1. Open SharePoint Designer, and open the page where
you want the rolled up list to be displayed.



2.      
2. Insert the
Data View Web Part
on the page.



3.      
3. Select the list that you want to use as a data
source for the DVWP. This is the list that you want to roll up across the site
hierarchy



4.      
4. Customize the display of DVWP such as number of
columns, layout, and so on.



5.      
5. Switch to the code view and in the code find the
DataSourceMode property in
SPDataSource for your DVWP. Here is
the sample SPDataSource of DVWP:


<SharePoint:SPDataSource
runat="server"



DataSourceMode
="List"



SelectCommand
="<View></View>"


id="DataSource1"
>


<SelectParameters>


<WebPartPages:DataFormParameter
Name="ListID"



ParameterKey
="ListID"



PropertyName
="ParameterValues"



DefaultValue
="GGGGGGGG-HHHH-CCCC-JJJJ-KKKKKKKK1111"
/>


</SelectParameters>


</SharePoint:SPDataSource>



6.      
6. Change the value of the
DataSourceMode property from
List
to CrossList.



7.      
7. After that, go to the
SelectCommand Property. This is the property that we use to set a
query for the SPDataSource of DVWP.



8.      
8. Add
<Webs Scope='Recursive'></Webs>

immediately after the opening quote and leave the rest of the
Selectcommand as it is:


DataSourceMode
="CrossList"


SelectCommand="<Webs
Scope='Recursive'></Webs ><View></View>
"

Here, the Webs element
defines the scope of the query.

Note: You can use CAML query
to customize the Selectcommand to
filter the DVWP.



9.      
9. Immediately after
Selectcommand, you will see <SelectParameters>, <DeleteParameters>
and <UpdateParameters>. Delete these as they are not necessary for the
CrossList mode.




10.  
10. Go to <ParameterBinding> section.




11.  
11. Find the line <ParameterBinding Name="ListID"
Location="None" />. Remove the
DafaultValue
property; it is irrelevant in this mode.



12.  
12. Check the line <ParameterBinding Name=”WebURL”
Location=”None” DefaultValue=”/sitename/subsitename/”/>.



13.  
13. Make sure that the
DefaultValue points to the “root
site as from where you would like the rollup to work.



14.  
14. Now save the page and test it in your browser.

I hope this gives you some
ideas for using the Data View Web Part. Happy coding! Email me if you have any
questions:
[email protected]



________________________________________


ABOUT ME

Kiefer Consulting, Inc.
is a trusted leader in .NET application development and California’s leader in
State Government SharePoint deployments, providing real business solutions using
Microsoft .NET technologies. With a 22 year track record of business success,
the firm has experience ranging from the first .NET releases all the way to
legacy mainframe systems. Kiefer consultants are experts in the technologies
they deploy, so clients always get best value solutions that balance Industry
Best Practices and new technologies. Register now for Kiefer’s 2010 events
and Edunarsb :

http://www.kieferconsulting.com


Proud Sponsor of the


ssps_logo.jpg

June 2nd and 3rd, Sheraton Grand |


www.sacspsummit.com

 

More by Author

Must Read