Wednesday, 18 December 2013

SharePoint Get Specific Folder List Items

You can also check whether item is folder or list item using "FileSystemObjectType"

var context = SP.ClientContext.get_current();
var web = context.get_web();

//doc is a document library server relative url
var folder = web.getFolderByServerRelativeUrl("Documents/Wildlife");

//var parentFolder = folder.get_parentFolder();
//context.load(parentFolder);

context.load(folder);
context. executeQueryAsync(function(){

var query = new SP.CamlQuery();
query.set_folderServerRelativeUrl(folder.get_serverRelativeUrl());
var allItems = list.getItems(query);
context.load(allItems, "Include(Title, FileSystemObjectType, File)");

context.executeQueryAsync(function(){
debugger;
var itemsEnumerator = allItems.getEnumerator();
while(itemsEnumerator.moveNext()){
var item = itemsEnumerator.get_current();
var fileType = item.get_fileSystemObjectType();
//get the detailed information

 var title = item.get_item("Title")

}
}, function(sender, args){debugger;});

}, function(sender, args){debugger;});

Share This!


No comments:

Post a Comment

Translate

Total Pageviews

Powered By Blogger · Designed By Seo Blogger Templates