Placing Share Documents subfolder as a webpart in SharePoint

sharepoint

I want to place a Webpart on a page that holds a subfolder of the Document Library in SharePoint, but somehow, the only thing I get is the root folder of the document library.

Is there a Webpart that fills this need?

Best Answer

Here is how to do it in Sharepoint 2010 with only Javascript, no SharePoint Designer necessary.

  1. create a document library web part on your web part page
  2. change the view to show all items without folders and set the item limit to a sufficiently large number so that there are no batches
  3. add Content Editor web part below document library web part
  4. Add the following javascript and change the the first variable to meet your needs

Note: If you have more than one Document Library web part, you will need to add to this code.

<script type="text/javascript" language="javascript">

    //change this to meet your needs
    var patt = /FOLDER%20TO%20SEARCH/gi; 
    var x = document.getElementsByTagName("TD"); // find all of the TDs
    var i=0; 

    for (i=0;i<x.length;i++)
    {
        if (x[i].className =="ms-vb-title") //find the TDs styled for documents
        {
            var y = x[i].getElementsByTagName("A");  //this gets the URL linked to the name field
            //conveniently the URL is the first variable in the array. YMMV.
            var title = y[0];  

            //search for pattern
            var result = patt.test(title);

            //If the pattern isn't in that row, do not display the row
            if ( !result )
            {
                x[i].parentNode.style.display = "none"; //and hide the row            
            }
        }
    }   
</script> 
Related Topic