SharePoint 2007 had a commonly used feature that enabled users to create views on lists that grouped by Content Type.
For some reason, this feature was removed from the user interface in SharePoint 2010.
Solution 1: The Easy Method
If you wish to do this today, you can do this using SharePoint Designer to create a view and then change the Xsl to specify a different field name to group by (e.g. “ContentType”).
Solution 2: The Better Method
Alternative, we could try and get our options added to the ViewEdit.aspx page. Options aren’t great for this as it’s a _layouts (application) page, and therefore we can’t just edit it in the browser or SharePoint Designer.
You could add a piece of JavaScript to do this though. Plan a) would be to add this to the bottom of you v4.master, and customise this for the whole site/site collection.
Plan b) would be to create something like a sandbox solution that deploys a “scriptlink” element, placing the script on every page that gets rendered.
I’ve create a CodePlex project for plan b). Here’s some of the code. Firstly, here’s the JavaScript I’d like to run on every page. It simply creates a new <option> tag in HTML and adds it to the drop down list if it exists on the page. Let’s call it “ListViewEdit.js”.
_spBodyOnLoadFunctionNames.push("jbCTFix"); function jbCTFix() { jbCTKludge('idGroupField1'); jbCTKludge('idGroupField2'); } function jbCTKludge(selName) { var sel = document.getElementById(selName); if (sel) { if (sel.selectedIndex >= 0) { var o = document.createElement('option'); o.text = 'Content Type'; o.value = 'tp_ContentType'; var prev = sel.options[sel.selectedIndex]; try { sel.add(o, prev); } catch (ex) { sel.add(o, sel.selectedIndex); } } } }
Next, here’s the element manifest to apply this on each page in the site collection.
<?xml version="1.0" encoding="utf-8"?> <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <CustomAction Id="Ribbon.Library.Actions.Scripts" Location ="ScriptLink" ScriptSrc="~site/ListViewEdit/ListViewEdit.js" /> <Module Name="ListViewEdit"> <File Path="ListViewEditListViewEdit.js" Url="ListViewEdit/ListViewEdit.js" /> </Module> </Elements>
You can download the full project and source code for the SharePoint 2010 ViewEdit Group by Content Type project from the CodePlex project here: sp10ctgrouping.codeplex.com
You can leave a response, or trackback from your own site.

How do you deploy this solution on sharepoint online? I added and activated the solution but the options for group by content type does not show….
Thanks,
Mark
Hi Mark!
I tried this on Office 365′s SharePoint Online just now. It all seems to work. Did you activate the “joelblogs.co.uk List View Group by Content Type” site feature?
Hope this helps!
joel
I’ve added, installed, and activated the feature and still see no “Content Type” option in the Group By select box. This is a list that uses multiple content types. Not sure what I could be doing wrong, but it’s simply not working.
Okay, I found it. The issue is that when you click the select box, it defaults to the “None” option, which is at the first index in the otherwise alphabetically-sorted list. Your script injects the “Content Type” option above that option (not in alphabetical order), and ends up being hidden. You might want to mention this quirk on this blog and your CodePlex site, as it is very easy to miss.
Hi Furiant,
Many thanks for your comments. Hope you find my code to be of use.
Please note that the second screenshot on the CodePlex page (http://sp10ctgrouping.codeplex.com/) shows this. Thank you for flagging this up. I have now added an extra item to the Known Issues list on the page in an attempt to make that clearer.
Kind regards,
Joel
Such a great article! I go with two approaches and they all fine :)
However, there is an issue still remain, the content types cannot be sorted. Seem that they are sorted by “ContentTypeID” instead of “ContentType”. Anyone experience on this, please advice me
Thanks