SharePoint 2010: How to list documents within a subfolder in a webpart?

Overview

Using the document library webpart on a site page, will always display the top level folder. If you would like to display only files within a subfolder. The following is one way to do it in SharePoint 2010.

Step 1: Create a View

  • Go to your document library (For example: Shared Documents)
  • Click Settings menu and select Create View
  • Click Standard View
  • Give the view a name (For example: Folder View)
  • Pick the columns to display, for example, Type (icon linked to document) – Name (linked to document with edit menu)
  • Limit the number of items displayed by expanding “Item Limit” (Example: 10)
  • Tabular View: uncheck “Allow individual item checkboxes”
  • Click OK to create the view

Step 2: Create the page to display the list

  • Open SharePoint Designer and open your site
  • Go to Lists and Libraries > Shared Documents
  • Under Views section, double click Folder View – make sure you are displaying the page in Design view (tabs at the bottom left of the edit screen)
  • Click the web part within the place holder area, it’s probably called something like “WebPartPages:XsltListViewWebPart”, right-click and select Copy
  • Select All Files under the Site Object panel on the left, you will then see the site top level folder on the right.
  • Anywhere in the blank area on the right panel, right click, and select New > ASPX
  • Name the file to a useful name such as SharedDocumentsFolderView.aspx
  • Double-click the new ASPX file to open it in the editor – make sure you are displaying the page in Design view (tabs at the bottom left of the edit screen)
  • Click in the form box and then right-click and select Paste
  • Click File, Save (you can close SharePoint Designer now)

Step 3: Get the URL to the folder

  • Open a new browser and navigation to the new page. Probably something like: http://intranet/sites/testsite/SharedDocumentsFolderView.aspx
  • Click on the folder you want displayed. The URL will now look something like: http://intranet/sites/testsite/SharedDocumentsFolderView.aspx?RootFolder=%2fsites%2ftest%2fShared%20Documents%2fsub1&FolderCTID;=&View;=%7bE0AECBEA%2d20BB%2d4BC3%2d98BC%2dE65D4ADB9DB1%7d
  • Copy this URL

Step 4: Add the web part to your home page

  • Return to a browser and display your web site’s home page
  • Click Site Actions and Edit Page
  • Delete the web part you added earlier for your library
  • Click Add a Web Part
  • Add the Page Viewer web part
  • From this web part click Edit Shared Web Part
  • Paste the URL to your new custom page in the Link box
  • Change any other properties needed. Most likely are:
  • Appearance > Title Appearance > Chrome Type
  • Advanced > Title Url (most likely a link to the full library)
  • Advanced > Description
  • Click OK
DONE

There is a minor problem to me that the webpart always shows horizontal scroll bar which I don’t know how to get rid off, anyone know how to fix this would be greatly appreciated.

The above instruction is inspired by Mike Smith’s post here:
http://techtrainingnotes.blogspot.com.au/2008/04/sharepoint-web-part-for-document.html

Leave A Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.