0

I have gotten a big document library. I must show only documents which are in specific folder. How could I show these documents? I have got many folders, but I want to show only the content of one of them.

2

Using the following CAML query:

<Query>
   <Where>
      <Contains>
         <FieldRef Name='FileDirRef'/><Value Type='Lookup'>FolderName</Value>
      </Contains>
    </Where>
</Query>

and CAML query options:

<QueryOptions>
   <ViewAttributes Scope='RecursiveAll' />
   <OptimizeFor>FolderUrls</OptimizeFor>
</QueryOptions>

you could specify to retrieve only items from a specific folder named FolderName

QueryOptions element is used for specifying Scope property, in our case scope option is set to Show all files and all subfolders of all folders

How to customize CAML of a List View via SharePoint Designer (SPD)

Let's say we need to display items from a folder named Orders

Steps:

  1. Open List View form page in SPD (AllItems.aspx for a default view)
  2. Replace Query element with the following one:
    <Query><Where><Contains><FieldRef Name='FileDirRef'/><Value Type='Lookup'>Orders</Value></Contains></Where></Query>
  3. Insert the following element after Query element: <QueryOptions><ViewAttributes Scope='RecursiveAll'/><OptimizeFor>FolderUrls</OptimizeFor></QueryOptions>

That's it.

Update

In SharePoint 2013 instead of step 3, specify attribute Scope='RecursiveAll' for a View element.

  • And how get Scope folder View in Sharepoint 2013 ? – Grzegorz Z Jul 23 '14 at 0:25
  • 1
    Open the form page where list view resides, for example default view page for a Documents library is located here: /Shared Documents/Forms/AllItems.aspx. Find the List View web part declaration and then just follow the steps provided in the answer. – Vadim Gremyachev Jul 23 '14 at 7:08
  • 1
    I confirm that it does not work as expected in SharePoint 2013 since, it seems, QueryOptions does not affect in XLV. The solution, instead of inserting QueryOptions element (step 3), update View element by specifying attribute Scope="RecursiveAll" – Vadim Gremyachev Jul 23 '14 at 13:38
  • 1
    The answer has been updated. – Vadim Gremyachev Jul 23 '14 at 13:40
  • 1
    Worked perfectly with SPD 2013 – George Feb 15 at 13:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.