Hi folks,
Currently I am working on a SharePoint 2010 Migration (from MOSS 2007). Most part of the work is done by scripting, however some tasks can be done manually because is much faster.
I include in these tasks quick fixes, which can be made by the user interface. Just telling that, because I had to repair some views that contain groupings and noticed that in SharePoint 2010, the option for grouping by Content Type is no longer available for users! What to do in this case? SharePoint Designer helps us to solve this problem.
Simulating the creation of view grouped by Content Type
A user needs to create a view that groups items by Content Type. How to accomplish this task?
In the Figure 1 there is a Document Library which contains some documents. Select the option Create View directly through this visualisation.
Figure 1 – Option for creating a view
The next step is to choose the view format, in this case a Standard View can be chosen, according to the Figure 2:
Figure 2 – Choosing the view format
Name the view to Grouped by Content Type (for example), according to the Figure 3, then go to the Group By section and select the option Content Type according to the Figure 4. Oops…Where is it? In MOSS 2007 that was available!
Figure 3 – View Name
Figure 4 - Column selection for grouping by
The Content Type option is no longer available in SharePoint 2010! In order not to encounter such pranks during the SharePoint 2010 Migration, do usability testing with real users, because they work everyday with SharePoint and know what is essential for their daily tasks.
Using the UI there is no exit, just save the view.
Workaround utilising SharePoint Designer 2010
Open the SharePoint Designer against the Web Site in which the Document Library was created, according to the Figure 5:
Figure 5 - Document Library
Skip to the opening of the newly created view according to the Figure 6:
Figure 6 - Newly created view selection
In regards to the Grouping By section, this is the XMLDefinition snippet that was created automatically after saving the view. In other words, it is empty! As we can see in the Figure 7, just the description of the empty element Query is available:
Figure 7 - Empty XMLDefinition Snippet
Alter this code snippet to contain the group by Content Type as per Figure 8. It does the trick:
Figure 8 - Grouping by defined in the XMLDefinition
The same code snippet is below for copying:
Code Snippet
- <GroupBy Collapse="TRUE" GroupLimit="100">
- <FieldRef Name="ContentType"/>
- </GroupBy>
Note: This code snippet defines the grouping by Content Type, besides, it defines that items will be collapsed by default and limited for displaying 100 items per grouping by.
In the end here we have the expected outcome, according to the Figure 9:
Figure 9 - Final Outcome
Finally we've got the expected outcome! A task that was simple before, now just can be done with the utilisation of a tool, and just in case the user has privileges for that.
Reference:
SharePoint Developer Center Forum
Cheers,
Marcel Medina
Click here to read the same content in Portuguese.