Follow me on Twitter: @eusp

Adventures with the “New Folder” Option in a Document Library

Original Publication Date: Thursday, March 12, 2009
Filed Under: Document Management, Toni Frankola, Web Parts, jquery
SharePoint User Level: Power User

 

On a project I had to create a custom folder content type. I added it to a document library as a content type (as shown in the figure below).

Adventures with New Folder

The default folder content type cannot be removed. Unlike a document, it cannot be removed as other document content types. However, there is an option in Advanced Document Library settings which allows you to turn it off.

Adventures with New Folder

Unfortunately, turning it off, leads to a new set of problems, as shown below. Once you turn off folders, everything in a document library will be reordered alphabetically, mixing folders and documents as if they were entities of the same type.

Adventures with New Folder

So, how to solve this problem? I wanted the ability to use folders in a document library, but I also wanted to have a valid sort order. I have been monitoring what Paul Grenier is doing with JQuery and I realized that this is the way to go. I developed a simple JQuery script and packed it as a web part. You just need to place it below your document library and you are good to go. This script is going to hide the default folder option from end users but folders and files in your document library will still be sorted in the correct way.


Adventures with New Folder

Adventures with New Folder

You can download my web part here, or just use the following script. Please note: The script has been tested with US English language settings, but you will probably need to make minor adjustments to make it work on your local settings (Replace the word “Folder” with your local translation) .

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<script type="text/javascript">
if(typeof jQuery==’undefined’){
                var jQPath="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/"; 
                document.write(’<script src="’,jQPath,’jquery.min.js" type="text/javascript"><\/script>’);
}
</script>
<script type="text/javascript">
                $("td[class='ms-splitbuttondropdown']").click(function(){
                                $("tr[text='Folder']").hide();
                });
 
                $(’table[onmouseover*="MMU_PopMenuIfShowing"]‘).mouseover(function(){
                                $("tr[text='Folder']").hide();
                });
</script>

Toni FrankolaAuthor: Toni Frankola SharePoint Use Cases Toni started his Web adventure in late 90’s and has been working with various web technologies ever since.

Toni is leading project engagements and managing a team of consultants specializing in Microsoft technologies. His primary focus is on Microsoft Office SharePoint and Dynamics CRM. He works at Perpetuum Mobile, a Microsoft Gold Partner from Croatia.

Spread the word...
  • Digg
  • Facebook
  • StumbleUpon
  • Google Bookmarks
  • LinkedIn
  • Reddit

Notify me of comments to this article:


Comments

2 Responses to “Adventures with the “New Folder” Option in a Document Library”

  1. Sharepoint Use Cases on March 18th, 2009 11:46 am

    Adventures with the “New Folder” Option in a Document Library…

    I just published a new article at EndUserSharePoint.com about custom folder content type and problems…

  2. Dean on August 19th, 2009 10:13 am

    Toni, I have created a Folder content type, added it to a doc library, added a new folder using this new Folder content type and then saved the library as a template. When i create a new doc lib from the template, it contains a folder but it has the default Folder content type instead of the custom folder content type. have you experienced this or know what might cause this?

    TIA
    Dean

Leave a Reply