In SharePoint and using SPServices, I am trying to view folder contents of a specific subfolder of a document library (and not every single file & folder inside the library). The library structure looks like this:
List Name: Shared Documents
Listing out the top-level folders is easy enough with GetListItems but I want to the let the user click on one of the folders and list and list only the direct children of the subfolder.
So, if someone clicks on "Folder #1" then I want to show them only the following:
I have absolutely no idea how to list out the direct children of a specific subfolder.
Can anyone help?
In order to restrict query for a specific folder, CAMLQueryOptions
parameter with Folder
value could be specified:
<QueryOptions>
<Folder>/SiteName/Lists/Links/folder/subFolder</Folder>
</QueryOptions>
var listName = "Shared Documents";
var folderName = "/Shared Documents/Folder #1";
$().SPServices({
operation: "GetListItems",
async: false,
listName: listName,
CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",
CAMLQueryOptions: "<QueryOptions><Folder>" + folderName + "</Folder></QueryOptions>",
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function() {
var title = $(this).attr("ows_Title");
console.log(title);
});
}
});
Please follow this thread for a more details.