locked
Create a webpart to show subfolder of existing document library RRS feed

  • Question

  • Hi

    As above I have a document library called 'Test' that has 10 folders in it and various files in each folder.

    I now want to create a web part of some kind on a page in my site, but have it display as a webpart and defaulting to the contents of folder C that is within 'Test'

    For some reason the web part only displays the document library as a whole and causes the user to navigate to C within the web part - how can use the full link of folder C as the default of the web part?

    I'd prefer to not do this in sharepoint designer as I have no experience with it and would have thought this is something that you could easily achieve.

    Thanks

    Thursday, July 18, 2013 4:20 PM

Answers

  • Modifying a library view is one of the simpler tasks in SharePoint Designer.

    First, using the browser, you need to create the view you will use to view files inside the folders of your library. Select the columns you want to display, how you want them sorted and select the Folders option "show all items without folders"

    Then in SPD open the site, on the left is the Navigation and Site Objects pane. Under Site Objects click on Lists and Libraries, select the library. The Views will be displayed on the right, click on the view you've created. Click the View tab and switch to Code view. Scroll down until you see the XsltListViewWebPart (a library view is a page with one ListView web part). In the XML you'll see a <Query> tag inside the <View> tag. It will have an <OrderBy> tag (for sorting). Below that add the <Where> tag I showed you earlier.

    If you want to check the folder names before adding the <Where> clause you can add the <FieldRef Name="FileDirRef"/> to the <ViewFields> tag. Then save and preview your view.

    Tom


    SharePoint Systems Officer, Capital Regional District, BC, Canada

    Friday, July 19, 2013 4:09 PM

All replies

  • Hi MJ, not sure what web part you're using, but have you actually clicked into the folder and then copied that URL in the address bar? Then use that as the "destination" in your web part.

    cameron rautmann

    Thursday, July 18, 2013 7:48 PM
  • You can do that in SharePoint Designer, but I don't think there's a way to do it through the browser. What you need is a view that "shows all items without folders" (under the Folder setting), but you need to then add a custom filter (in the CAML query) that includes this:

    <Where>
      <Eq>
        <FieldRef Name="FileDirRef"/>
        <Value Type="Computed">/site/library/folder</Value>
      </Eq>
    </Where>

    That’s using a hidden column that contains the path to the folder, and only including values that match the path to your folder.


    SharePoint Systems Officer, Capital Regional District, BC, Canada

    Thursday, July 18, 2013 9:48 PM
  • Thanks Tom, that doesn't mean much to me to be honest, I've just started reading a SPD book so it's all new to me.  Even navigating around proves very difficult so I'll come back to this when I have some more experience or find a guide with screenshots.

    Thanks again

    M

    Friday, July 19, 2013 7:24 AM
  • Modifying a library view is one of the simpler tasks in SharePoint Designer.

    First, using the browser, you need to create the view you will use to view files inside the folders of your library. Select the columns you want to display, how you want them sorted and select the Folders option "show all items without folders"

    Then in SPD open the site, on the left is the Navigation and Site Objects pane. Under Site Objects click on Lists and Libraries, select the library. The Views will be displayed on the right, click on the view you've created. Click the View tab and switch to Code view. Scroll down until you see the XsltListViewWebPart (a library view is a page with one ListView web part). In the XML you'll see a <Query> tag inside the <View> tag. It will have an <OrderBy> tag (for sorting). Below that add the <Where> tag I showed you earlier.

    If you want to check the folder names before adding the <Where> clause you can add the <FieldRef Name="FileDirRef"/> to the <ViewFields> tag. Then save and preview your view.

    Tom


    SharePoint Systems Officer, Capital Regional District, BC, Canada

    Friday, July 19, 2013 4:09 PM
  • Thanks for the detail Tom, I'll give this a try later today and let you know how it goes
    Monday, July 22, 2013 8:45 AM
  • no such option 'destination', within documents libary webpaty
    Thursday, March 26, 2015 12:00 PM
  • is there a chance to achieve that without sharepoint designer?
    Thursday, March 26, 2015 12:01 PM
  • This worked for me

    Echo Train Nashville TN

    Tuesday, April 21, 2015 7:29 PM
  • Aren't you finding it that, the "ease" of SharePoint forces you to be so affluent in a niche development skill that you could just learn a framework like .Net or Ruby and do REAL development?  
    Monday, February 29, 2016 6:41 PM
  • Anyone able to show screen shots or youtube video?
    Tuesday, November 15, 2016 7:23 PM
  • You can use a Content Query web-part (from the Content Rollup webpart category)

    1. add the Content Query web-part

    2. select 'Edit Web Part'

    3. under 'Query' > 'Source:' - enter the list/library. In your case, click 'browse' from the Show items on the following list

    4. select the library you want to display, click 'Apply'

    5. down at the 'Additional Filters:' portion, Add 'URL Path' + 'contains' + '/C/' (which is the subfolder you wanted to display)


    Wednesday, November 16, 2016 4:01 PM
  • This is a great solution--worked perfectly.  I did notice, however, that when dragging and dropping files to upload into the list view webpart, it get's uploaded to the main document library, not in the folder I was filtering for.  Is there a somewhat elegant way to make the upload go to the same folder when dragging and dropping info the list view webpart?

    Thanks!

    Thursday, December 15, 2016 12:02 AM
  • No, you cannot drag and drop into a folder because the webpart does not adhere to that UI metaphor. You can use the full drag and drop if you are  able to invoke Open with Windows Explorer from the Actions menu option.

    Tuesday, December 20, 2016 10:57 PM
  • I tried creating the same way but no luck, I am able to see all documents in all folders .I just want to view the documents in my subfolder only
    Wednesday, September 27, 2017 3:12 PM
  • Hi Kartheek,

    I wrote a quick blog - http://www.tombenjamin.ca/blog/uncategorized/using-caml-query-show-files-folder/ - with some screenshots to illustrate the process of modifying the view in SharePoint Designer.

    I hope that helps.

    Tom


    SharePoint Systems Officer, Capital Regional District, BC, Canada


    • Edited by Tom Benjamin Wednesday, September 27, 2017 7:43 PM Added link to blog
    Wednesday, September 27, 2017 7:43 PM