SharePoint: Group By on more than 2 columns in a view (SP 2010)
This is an update of an article written for SharePoint 2007. Many of the steps are the same in both 2007 and 2010, but both the SharePoint Designer steps and the default web part ud for views have changed.
Group By on more than 2 columns in a view
In my SharePoint class I have often been of asked how to group on more than two levels in a view. I have always given the quick answer of "u SharePoint Designer"!
But, some of you have asked "How?". You may be sorry you asked… but here goes…
Goals: 忙的句子
∙ Create a view with nested groups deeper than just 2 levels
∙ 短趾雕Put the counts and totals at the bottom of each ction.
∙ Do the above with no custom web parts, custom XSLT or anything that has to be deployed to the rver.
Sample:
Secrets and Tricks needed:
∙ It can't be done "out of the box" in the browr
∙ SharePoint Designer is needed to make the edits
∙ You need to convert the view web part to a SharePoint Designer Data Form Web Part
∙ You need a Sort and Group cret
∙ You need to fix the footer rows
∙ You need to manually add your totals, averages, counts etc.
虞美人寄公度Warning!
SharePoint 2010 does not consider a page with a Data From Web Part to be a “view”. It only believes that a page is a “view” when it has an “Xslt List View Web Part”. In 2007 we could create a new view, edit it in SharePoint Designer as much as we wanted, and it was still a view. In 2010, SharePoint will not recognize a page without a XsltListViewWebPart as a view.
So before you start…
∙ If you just need a page with your list nicely grouped, it may be best just to create a web part page and store it in a library. Then add the Data Form Web Part using the steps below.
∙ 唯美音乐If you want the page to be treated as a view, leave the XsltListViewWebPart on the page, but make it hidden. Then add the Data Form Web Part below the existing web using the steps below.
o In SP 2010, a view page with an added web part introduces a bug or two. The ribbon will not be displayed. The view dropdown in the page title area will be missing the dropdown to lect another view.
My Example:
∙ I have a simple list (actually imported from Excel) with the columns: ID1, Bike, BikeType, BikeSize, BikeColor and Retail (price).
∙ 深圳租房合同I want to group this on BikeType, BikeSize, BikeColor and count the items and sum or a
verage the price in each group.
Create a new Standard View from the list's view menu.
Don't bother with any options as we are just going to delete the default list web part.
Or just create an empty web part page. (e “Warning” above)
The “before” – just a standard view with lected columns:
滴水观音有毒
If using an existing view page:cost
∙ 无花果叶Open your site with SharePoint Designer and click the Lists and Libraries node in the Site Objects pane
∙ Click your list (“Bikes” in my example)
∙ Click your view you created earlier (“Grouped” in my example)
Otherwi create a new web part page in a library
∙ Notes (background only, you can skip this):
o The view is now being displayed using a XsltListViewWebPart (It was a ListViewWebPart in SP 2007) and can only be customized with the same options as found using a browr ("Modify View")
o The XsltListViewWebPart has the same grouping limitations and the ListViewWebPart (2 levels of grouping)
o For more info on what has changed from the 2007 ListViewWebPart and the XsltListViewWebPart e /en-us/library/ff806162.aspx and /en-us/library/ff604021.aspx
o SharePoint Designer 2010 has two web parts for lists:
▪ XsltListViewWebPart - this is the web part ud when you create a new View
▪ DataFormWebPart – created from SharePoint Designer using Inrt, Empty Data View
o SPD 2010 adds a bit of confusion when trying to add a “Data View”
▪ When you click Inrt, (pick an existing list) SPD inrts an XsltListViewWebPart
▪ When you click Inrt, Empty Data View SPD inrts a DataFormWebPart
∙ If starting with an existing view, delete or hide the existing web part.
o Delete: In the Design window click in the web part, click the WebPartPages:XsltListVie
wWebPart tab, press the Delete key
or
in the Code window lect the entire <WebPartPages:XsltListViewWebPart tag (including the start and end tags) and delete the code
o Hide: In the Design window click in the web part. In the Ribbon in the List View Tools ction click the Web Part tab and then click Properties. In the Layouts ction of properties click Hidden