locked
Option to Group By: Content Type is missing from view settings. RRS feed

  • Question

  • In testing for migrating/upgrading our WSS 3.0 environment to SharePoint 2010, I have noticed that there is no longer an option to group list items by the Content Type column in view settings.  Is this by design, or a known issue that still needs to be fixed?  This is using the recent SharePoint 2010 Enterprise RTM.

    Tuesday, May 11, 2010 4:54 PM

Answers

  • Hi Carthjr,

    You right - this option is missing from the View Settings.....

    SharePoint Designer to the rescue!!!

    Open the list in SharePoint designer and access the views aspx page - by default this will be AllItems.aspx. In the aspx page, locate the XML for the View and insert a <GroupBy> element. Below is an example that will cause the view to group by Content Type :

    <View Name="{37ADFC3F-54DD-4D1F-9C19-A0F122C8DBD8}" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" Type="HTML" DisplayName="All Documents" Url="/forms test/Forms/AllItems.aspx" Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/images/dlicon.png">
    				<Query>
    					<GroupBy Collapse="TRUE" GroupLimit="30">
    						<FieldRef Name="ContentType"/>
    					</GroupBy>
    					<OrderBy>
    						<FieldRef Name="FileLeafRef"/>
    					</OrderBy>
    				</Query>
    				<ViewFields>
    					<FieldRef Name="DocIcon"/>
    					<FieldRef Name="LinkFilename"/>
    					<FieldRef Name="Modified"/>
    					<FieldRef Name="Editor"/>
    					<FieldRef Name="CheckoutUser"/>
    					<FieldRef Name="Class_x0020_1"/>
    					<FieldRef Name="Type_x0020_1"/>
    				</ViewFields>
    				<RowLimit Paged="TRUE">30</RowLimit>
    				<Aggregations Value="Off"/>
    				<Toolbar Type="Standard"/>
    			</View>
    

    I hope this helps...


    Brian C | Blog Site
    • Marked as answer by Carthjr Wednesday, May 19, 2010 7:30 PM
    Thursday, May 13, 2010 9:48 PM

All replies

  • Hi Carthjr,

    You right - this option is missing from the View Settings.....

    SharePoint Designer to the rescue!!!

    Open the list in SharePoint designer and access the views aspx page - by default this will be AllItems.aspx. In the aspx page, locate the XML for the View and insert a <GroupBy> element. Below is an example that will cause the view to group by Content Type :

    <View Name="{37ADFC3F-54DD-4D1F-9C19-A0F122C8DBD8}" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" Type="HTML" DisplayName="All Documents" Url="/forms test/Forms/AllItems.aspx" Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/images/dlicon.png">
    				<Query>
    					<GroupBy Collapse="TRUE" GroupLimit="30">
    						<FieldRef Name="ContentType"/>
    					</GroupBy>
    					<OrderBy>
    						<FieldRef Name="FileLeafRef"/>
    					</OrderBy>
    				</Query>
    				<ViewFields>
    					<FieldRef Name="DocIcon"/>
    					<FieldRef Name="LinkFilename"/>
    					<FieldRef Name="Modified"/>
    					<FieldRef Name="Editor"/>
    					<FieldRef Name="CheckoutUser"/>
    					<FieldRef Name="Class_x0020_1"/>
    					<FieldRef Name="Type_x0020_1"/>
    				</ViewFields>
    				<RowLimit Paged="TRUE">30</RowLimit>
    				<Aggregations Value="Off"/>
    				<Toolbar Type="Standard"/>
    			</View>
    

    I hope this helps...


    Brian C | Blog Site
    • Marked as answer by Carthjr Wednesday, May 19, 2010 7:30 PM
    Thursday, May 13, 2010 9:48 PM
  • Thanks for the reply Brian,

    I had planned using designer as a work around if this was, in fact, an intended change by MS. 

    Another option for this would be to user SharePoint Designer and write a simple workflow that copies the value of Content Type to a single line text column, then create view groupings based on that.  This would at least eliminate the need for creating any new grouped views in designer.

    Let's hope MS fixes this though...

    Friday, May 14, 2010 2:04 PM
  • +1 to the people who hope this becomes standard MOSS 2010 functionality. Sorts by content type are important to our users! (and adding custom columns to every library is really not efficient, nor do we have a large technical staff to support this implementation)
    Friday, May 14, 2010 5:26 PM
  • Thanks for the reply Brian,

    I had planned using designer as a work around if this was, in fact, an intended change by MS. 

    Another option for this would be to user SharePoint Designer and write a simple workflow that copies the value of Content Type to a single line text column, then create view groupings based on that.  This would at least eliminate the need for creating any new grouped views in designer.

    Let's hope MS fixes this though...


    Hi Carthjr,

    Building the proceess is good option.

    But I think to develop right view will be more robust. For example, in a case of renaming content type.

    Friday, May 14, 2010 5:44 PM
  • Hi Brian,

    This only works part way. It does indeed group the items by content type, but when I did this it made the drop-down menu on the files stop working. When I click on the down arrow that appears when I hover over an item all I get is "error on page" in the lower left of the screen, which makes this useless.

     

    Also, this would be very useful if it worked in Visual Studio. I tried a CAML query very similar to this when I create a new view and all I get is: "Cannot complete this action. Please try again". Is there any difference between doing this through Designer and doing it through VS?

    My query is this: 

    query = "<Query><GroupBy Collapse=\"TRUE\" GroupLimit=\"30\"><FieldRef Name=\"ContentType\"/></GroupBy><OrderBy>" +

     

    "<FieldRef Name=\"FileLeafRef\"/></OrderBy></Query>";

     

    Thanks,

    Scott

     

    string

    Wednesday, July 28, 2010 7:53 PM
  • p.s. thanks for the tip -- yes, this works  (it would be GREAT if this were built into the UI so that end-users could accomplish this, rather than admins through Designer!)
    Wednesday, October 20, 2010 4:57 PM
  • Adding the Query into the view worked for me also, until I made a template out of the list. When creating new lists from this template, I see the same error that Scott describes, where the context menu on items in the list no longer works. In the grouped view in fact, trying to select any item throws a JS error.

    So, it seems that the list view is not meant to be grouped by Content Type. Has anyone found any solutions to this JavaScript error?

    ~Michael

    Wednesday, October 20, 2010 5:27 PM
  • An afterthought: Another downside to using SP Designer to insert the Group By statement is that anytime you edit the view from the browser, the Group By option will be removed (since it's not an option in the browser). In order to maintain the grouping, the code has to be inserted via SP Designer after each time that you edit the view.


    ~Michael
    Wednesday, October 20, 2010 5:43 PM
  • Yeah, totally - thanks for pointing that out!  Yet another great reason for this to be a standard part of the Sharepoint UI!

    (They want us to use content types to label content -- but it needs to be easier to bring the power of content types forward to the end-user!)

    --Dave

    Wednesday, October 20, 2010 7:57 PM
  • In SP 2007, I created  a calculated column (Item Type) which used the formula =[Content Type]. this enabled me to use content type in places where it did not appear as a choice. This no longer works in SP 2010, but I was wondering if it's still possible to refer to the Content Type column in a calculated column, thus getting around the need for SharePoint Designer and some of the other fixes proposed? My efforts at discovering how to reference the column have so far been unsuccessful.

    Thursday, June 28, 2012 5:47 PM
  • You can do this in several ways: Sharepoint Designer, PowerShell, etc...

    But the easiest and fastest way I found is to do this:

    1. Edit the view you want to group by
    2. open Dev Tools on your browser (F12)
    3. in the group by drop down, edit the value of "None" to "tp_ContentType"

    Done!

    The only problem is that you must do this every time you want to change something on the view

    Tuesday, September 24, 2013 12:02 PM