Different list views for folders, content types and files in SharePoint 2010

There is a not well known feature of SharePoint I want to show. You can create different default list views for different content types.

As an example you have a top folder for specific orders which is automatically created by your customer when he orders something. Within this folder you and your customer exchange documents.

You goal is that when someone enters the order list he only sees his folder.

1. Attempt

My first opinion would be to create a list view with a specific filter. But here begins the problem: How should the filter look like ? If you set "Created By = [Me]" the customer will only see documents and folders he created. When you use "Created By = [Me] & Contenttype = Folder" he would not see subfolders created by others.

2. Attempt

The more elegant way is to use different content types for top folders and subfolders. Based on the content types you can create different default views.

2.1 Create Content Types

So create a new content type based on "Folder" content type. If you wish you can also add some fields to your content type. To create a new folder content type go to your web settings.

Add Site Content Type

Create a new folder content type


Attach the new content type to your list.

  1. Go to your list
  2. Open the list settings page
  3. Click on "Advanced Settings"
  4. Click on "Yes" at "Allow management of content types"
  5. Click "OK"
  6.  A new link "Add from existing site content types" appears on your list settings page. Click it and select your new folder content type.

Now create some folders with the new content type. Do not use the standard folder option from ribbon. Click on the "New Item" or "New Document" ribbon button.

Add folder with custom content type
Within these folders you must use the standard folders for the example to work.

2.2. Create different views

Now we will create 2 default views.  The first view is to show the top folder only to customer which created the folder.
  1. Go to your "Order" list
  2. Modify the standard "AllItems" view.
  3. Apply your filter in the "Filter" section
  4. In the "Folder" Section select "Show items inside folders" & "In the top-level folder"



The second view is for the content inside the top folders. We know that the top folders are created with an other content type than the subfolders. Subfolders are standard SharePoint folders. To create the new view:

  1. Go to your list
  2. Create a new standard view
  3. Click on "Make this the default view". Now you'll have 2 default views.
  4. Apply your filters and sortings
  5. In the "Folders" section now the greyed out 3rd option is available. Click on "In folders of content type" and select your content type.
  6. Click "OK"


If you made everything correctly you'll see in the List Settings page at the bottom following composition:

You have now 2 different views for your content types.

If you open your list you will also notice, that the view for your folder content type is only available within your subfolders.

Additional

The is much more with list views you can do. Have you ever realized the "Per-location view settings" on your list settings page. With this link you can also customize the view for each folder induvidually or per content type like shown in this blog.

Sources

Comments

Junior said…
Thanks for saving my life!
Unknown said…
Awesome! Thanks :-)

Popular posts from this blog

Open SharePoint 2010/2013 Display, Edit, New Forms in Modal Dialogs

Ways to redirect http requests in SharePoint

Using WebDav on IIS 7 to access UNC Paths