Post an Article
Technology Category : SharePoint
Document Library Tree View Web Part for SharePoint
By Kamal Verma
In this article we will discuss how to create a tree view web part for representation of SharePoint document library files and folders and its installation steps.
[Total Vote(s) : 5 ] [Current Rating : 4.4 ] Rate this Article Low High


Install DocumentLibraryTreeView.zip

DocumentLibraryTreeView.zip

Introduction

Document libraries are collections of files that you can share with team members on a Web based on Microsoft Windows SharePoint Services. It is the prominent feature of SharePoint that you can use to upload your main or core documents. Document Library is consist of a row and column in All documents view with links to the documents and folders. If you want to see the document of a folder in the document library, then you need to click on the folder and it will show you the list of files and folder nested in. But if the hierarchy become so long then it will be tedious to go to the depth of the folder hierarchy.

With comparison of this, tree view is the user friendly representation of the folders and files underneath. User can reach to the document at any level and also collapse and expand the folders as per need.

In this article we will discuss how to create a tree view web part for representation of SharePoint document library files and folders and its installation steps. 

Design & Functionality

The design of this web part will be like both grid view and tree view. We will remain the header row and columns (Title and file icon) of the default grid view representation and change the title column as tree view as shown in Figure 1.



Figure 1

User can select and change his target document library in an easy and graphical view. All the folders and files in the web part are sorted on the bases of creation date in descending order.

Core functionality of this web part is achieved by two functions named CreateTableStructure and GenerateChildFolderList. Collaspe and expand functionality has been achieved by using javascript which I have embed in the code. File’s icons have been set through GetFileImageName. 
 

Installation & Implementation

Follow below mentioned steps to install this web part:

• Copy the DocumentLibraryTreeView.dll into SharePoint application bin directory.
 
• Open the Web.config file of SharePoint site with Visual Studio.

• Locate a safe control entry and make a copy below the original line.

• Notice that all of Microsoft’s lines use a four part strong name. This example does not need a four part name since we are not using strong names. You can use only the Assembly name without the .dll extension, in this case "DocumentLibraryTreeView". Replace the namespace, in this case "DocumentLibraryTreeView".

• Finally, fill “*” in the type name.

<SafeControl Assembly="DocumentLibraryTreeView" Namespace="DocumentLibraryTreeView" TypeName="*" />

• Also change the trust level in web.config.

<trust level="WSS_Medium" originUrl="" />

• The act of saving the Web.config file is enough to reset the application, so there is no need to perform an iisreset. The site will automatically recycle to get the changes.

• Open the SharePoint application.

• Goto Site Actions -> Site Settings

• Under Gallaries click Web Parts link as shown in Figure 2.


Figure 2

• Click on New in toolbar as shown in Figure 3.


Figure 3

• All the web parts which are available for this SharePoint application are shown here. There should be one more web part available here which you have just added as shown in Figure 4.


Figure 4

• Check the TreeView web part and click on Populate Gallery button.

• Now it is available for use as shown in Figure 5.


Figure 5

• Go to the web page on which you want to display this TreeView web part.

• Goto Site Actions -> Edit Page.

• Click on Add a Web Part link in the header as shown in Figure 6.


Figure 6

• You can see the TreeView Web Part in the Miscellaneous category. Choose the web part and press Add button.


Figure 7


• Edit the web part and choose “Modify Shared Webpart”. In the Property pane choose the document library and press Apply button as shown in Figure 8.


Figure 8

Limitations

TreeView web part can only be used with document library.

About Kamal

  • Country : India  Country Flag
  • Kamal Verma is an intermediate level software developer, having  experiences in ASP.Net and SharePoint, born in India in 1981, Post Graduated from Maharishi Dayanand university, Rohtak in 2005,
    and looking for a good future...

Top
Add Comment