Showing posts with label Group by. Show all posts
Showing posts with label Group by. Show all posts

Monday, May 4, 2015

SharePoint 2013 Group by content type

SharePoint 2013 Group by content type

Just like SharePoint 2010 it is not possible with SharePoint 2013 to create a view with a ‘group by’ or ‘sort’ for the content type column with the help of the the user interface. Fortunately we can create the ‘group by’ content type view with the help of SharePoint Designer and a bit of code. Sorting the view on content type is not possible with this solution. When using this solution be aware of the following downside. When the view is modified through code, you should no longer edit the view through the user interface. When you edit the view through the user interface the code will be removed automatically.
1. Create through the user interface the view you need.
2. Set the Group By on the column Created.
3. Save the view.
4. Open the view with SharePoint designer in the advanced mode.
5. Find the following code.
<GroupBy Collapse="TRUE" GroupLimit="30"><FieldRef Name="Created"/></GroupBy>
6. Change Created into ContentType
8. Save the changes.

Hope this help,

Friday, October 10, 2014

SharePoint Custom Grouping with XSLT

Sharepoint Custom Grouping With XSLT

For SharePoint solution where the look and feel or clean code is very important we often create custom header.xslt ContentQueryMain.xslt and ItemStyle.xstl files. The files are almost completely empty to provide us with maximal control. This also means we need to recreate functionality that normally works by default. A good example is the ability to group the results.
1. Create the custom XSLT files and link the files to the Content Query Web Part.
2. The following code is a complete example of a custom Content Query Main XSLT file. This code generates grouping.

    exclude-result-prefixes="x xsl cmswrt cbq" 
    <xsl:output method="xml" indent="no" media-type="text/html" omit-xml-declaration="yes"/>

  <xsl:key name="Grouping" match="Row" use="@GroupingColumn" />

  <xsl:template match="/">
 <xsl:for-each select="/dsQueryResponse/Rows/Row[generate-id(.)=generate-id(key('Grouping',@GroupingColumn))]/@GroupingColumn">
  <xsl:sort />
        <xsl:value-of select="."/>
        <xsl:for-each select="key('Grouping', .)">
         <br /><xsl:value-of select="@Title" />
3. Change the XSLT where needed
CQWP Custom Grouping

Wednesday, July 16, 2014

Gruop items by folder name

Group Items on Their Folder Name Inside a SharePoint Library

As you probably will know, folders could not be used in views to group documents. You could only group documents on their metadata.
Group Documents
Group Documents
A possible solution could be to add a new metadata field to the content type and manually add the folder name as the metadata value. It is very easy to add and requires no custom development, but it requires an extra manual step from the document creator.
This manual step can also be automated by a SharePoint 2010 Document library functionality called Column default value settings. It can be found on the document library settings page under the General settings section.
The Column default value settings enable you to define a default value for a metadata column per folder.
Default column value
Default column value


  • Go to the document library settings;
  • Create a new column called: Folder name (Single line of text);
  • Click on Column default value settings under the General settings section;
    Culumn default value settings
    Culumn default value settings
  • On the left side you will see your folders, and on the right site the columns for which you could give up a default value;
    Folders, columns
    Folders, columns
  • Click on the folder name, and after that on the column name;
    Default column value
    Default column value
  • Click Use this default value, and fill in the folder value and click OK;
  • Repeat this process for each folder.
Now when you upload a document to a folder, the Folder name column will automatically get the default value.
To prevent users being able to fill in their own value, you could hide the Folder name columnfrom the new and edit forms.
Hidde column from forms
Hidde column from forms


Group by on folder name
Group by on folder name

Attention: SharePoint Foundation

The Column default value functionality is not available in SharePoint Foundation.

How to export a schema.xml file for a list from a SharePoint site

How to export a schema.xml file for a list from a SharePoint site In sharepoint, we can retrieve the XML schema of any list by using ...