7

SharePoint REST API 获取文件夹下的项目数

 3 years ago
source link: https://www.cnblogs.com/jianyus/p/13276676.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

SharePoint REST API 获取文件夹下的项目数

  正文

  众所周知,SharePoint Online站点有列表数据5000条阈值的限制,而我们每次查询也只能够查询最多5000条数据。当然,这是由于SharePoint对于性能的让步,因为数据库每次查询超过5000条数据会有锁,为了避免这一情况而影响到性能,所以有了这样的限制。

  但是,我们很多时候需要查询数据列表总数,以前,我们都是先获取到数据表所有项目,再获取Count属性。其实,有更快捷的方式可以直接获取到列表总数,也就是下面的REST API.

$.ajax({
    url: "https://linyus.sharepoint.com/sites/ELearning/_api/web/GetFolderByServerRelativeUrl('Lists/MoreThan6K')/itemcount",
    headers: {
        "Accept": "application/json; odata=verbose"
    },
    contentType: "application/json; odata=verbose",
    success: function(data) {
        console.log(data.d.ItemCount);
    }
});

  结束语

  可能最近做SharePoint Online项目多一些,碰到了很多奇葩的问题。当然,又成长了不少,而且,SharePoint Framework框架对于开发来说,真的是非常不错!有兴趣可以尝试一下!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK