Mar
12
Adventures with the “New Folder” Option in a Document Library
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).

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.

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.

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.


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> |
Author: 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.
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…
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