• 数据量太大时,如何实现分页查询-JSOM


    利用Jsom实现分页查询:
    
    var data=[];
    function getItems()
    
    {
    
    licenceContext=new SP.ClientContext(); //var licenceContext =SP.ClientContext.get_current();
    
    licenceWeb=licenceContext.get_web();
    licenceList=licenceWeb.get_lists().getByTitle("listName"); 
    query_licence=new SP.CamlQuery();
    
    //需要哪些字段就将这些字段放到查询caml中,然后遍历时获取字段进行判断
    
    var queryTemp='<View><ViewFields>'
    +'<FieldRef Name="column1"/>'
    +'<FieldRef Name="column2"/>'
    +'<FieldRef Name="column3"/>'
    +'</ViewFields><RowLimit>1000</RowLimit></View>';
    
    //有时也会使用下列写法,但不一定有效
    
     
    
    /*var queryTemp = "<View>"
    + "<Query><Where>"
    + "<And>"
    + "<IsNotNull><FieldRef Name='column1'/></IsNotNull>"
    + "<And>"
    + "<Eq><FieldRef Name='column2'/><Value Type='Text'>A</Value></Eq>"
    + "<Eq><FieldRef Name='column3'/><Value Type='Text'>Y</Value></Eq>"
    + "</And>"
    + "</And>"
    + "</Where><OrderBy><FieldRef Name='column1' Ascending='false'/></OrderBy></Query>"
    
    + "<ViewFields>"
    + "<FieldRef Name='column1'/>"
    + "<FieldRef Name='column2'/>"
    + "<FieldRef Name='Status'/>"
    + "<FieldRef Name='column3'/>"
    + "<FieldRef Name='column4'/>"
    + "</ViewFields>"
    + "<RowLimit>5000</RowLimit>"
    +"</View>";*/
    
    query_licence.set_viewXml(queryTemp); 
    licenceCollListItem=licenceList.getItems(query_licence);
    licenceContext.load(licenceCollListItem);
    licenceContext.executeQueryAsync(Function.createDelegate(this,onQuerySucceeded),Function.createDelegate(this,onQueryFailed));
    }
    
    function onQuerySucceeded(){ 
    
    var listEnumerator=licenceCollListItem.getEnumerator();
    while(listEnumerator.moveNext())
    {
    var testObj={};
    var currentItem=listEnumerator.get_current();
    
    var column1=currentItem.get_item('column1')||"";
    var column2=currentItem.get_item("column2")||"";
    var column3=currentItem.get_item("column23")||"";
    testObj.column1=column1;
    testObj.column2=column2;
    testObj.column3=column3;
    data.push(testObj);
    }
    
    var position = licenceCollListItem.get_listItemCollectionPosition();
    if (position != null) 
    {
    query_licence.set_listItemCollectionPosition(position);
    licenceCollListItem = licenceList.getItems(query_licence); 
    licenceContext.load(licenceCollListItem); 
    licenceContext.executeQueryAsync(Function.createDelegate(this, onQuerySucceeded), Function.createDelegate(this,onQueryFailed));
    }
    
    else
    {
      var SkuObjColl=[];
      SkuObjColl = data.where(function (z) { return z.column1 == "条件1"&& z.column2 == "条件2" });//linq条件筛选
    }
    SkuObjColl.forEach(function(result){//数据处理});
    }
    
    function onQueryFailed(sender, args) {
    console.log('Request failed. 
    Error: ' + args.get_message() + '
    StackTrace: ' + args.get_stackTrace());
    }
    
     
  • 相关阅读:
    Mac Finder 里新建文本
    SourceTree 无法查看组织仓库
    Android Gradle 指定 Module 打包
    Mac 下安装安卓 apk 文件
    Android 瘦身之道 ---- so文件
    Android Google AdMob 广告接入示例
    Java 垃圾回收(GC) 泛读
    [麻雀虽小]记 简易Markdown阅读器 开发全过程
    Git 版本回滚
    线程与进程的区别及其通信方式
  • 原文地址:https://www.cnblogs.com/learning-life/p/10405256.html
Copyright © 2020-2023  润新知