如何查询&显示子网站上所有列表中的项目 [英] How To Query & Display Items from All Lists on a Subsite

查看:60
本文介绍了如何查询&显示子网站上所有列表中的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好, 


我希望查询并显示特定子网站上存在(并且将来会存在)的所有列表中的项目。  ;


以下是我目前的情况,但它没有产生任何警报,任何人都可以帮忙吗?


var siteUrl ='/< g class =" ; gr_ gr_31 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace"数据-GR-ID =" 31 QUOT; id =" 31"> mycollection< / g> / mysite';
$


function retrieveAllListProperties(){



  &NBSP; // var clientContext = new SP.ClientContext(siteUrl);

  &NBSP; // var oWebsite = clientContext.get_web();

  &NBSP; //this.collList = oWebsite.get_lists();

 

  &NBSP; //clientContext.load(collList);

    

var clientContext = new SP.ClientContext(siteUrl);

var oWebsite = clientContext.get_web();

this.collList = oWebsite.get_lists();
$


this.listInfoCollection = clientContext.loadQuery(collList);



  &NBSP; clientContext.executeQueryAsync(Function.createDelegate(this,this.onQuerySucceeded),Function.createDelegate(this,this.onQueryFailed));

}



函数onQuerySucceeded(){

$
  &NBSP; var listInfo ='';
$


  &NBSP; var listEnumerator = collList.getEnumerator();
$


  &NBSP; while(listEnumerator.moveNext()){

  &NBSP; &NBSP; &NBSP; var oList = listEnumerator.get_current();

  &NBSP; &NBSP; &NBSP; listInfo + ='Title:'+ oList.get_title()+'Created:'+ oList.get_created()。toString()+'\ n';

  &NBSP; }¥b $ b  &NBSP; alert(listInfo);

}



函数onQueryFailed(sender,args){

  &NBSP; alert('请求失败。'+ args.get_message()+'\ n'+ args.get_stackTrace());

}


解决方案



我刚刚浏览了你的代码片段,我不认为这会返回子网站下列表项的任何结果..你可能应该对CAML查询进行反对多个列表abd您可以将其范围限定到特定的子网站。 


请查看 如果您有任何疑问,请写下文。如果您有任何疑问,请与我联系。



https://plumsail.com/docs/ workflow-actions-pack / how-to / query%20multiple%20lists%20across%20multiple%20sites%20and%20group%20results.html




Hello, 

I am looking to query and display items from all of the lists that exist (and will exist in the future) on a specific subsite. 

Below is what I have so far but it is not producing any alert, can anyone help?

var siteUrl = '/<g class="gr_ gr_31 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="31" id="31">mycollection</g>/mysite';

function retrieveAllListProperties() {

    //var clientContext = new SP.ClientContext(siteUrl);
    //var oWebsite = clientContext.get_web();
    //this.collList = oWebsite.get_lists();
 
    //clientContext.load(collList);
    
var clientContext = new SP.ClientContext(siteUrl);
var oWebsite = clientContext.get_web();
this.collList = oWebsite.get_lists();

this.listInfoCollection = clientContext.loadQuery(collList);

    clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}

function onQuerySucceeded() {

    var listInfo = '';

    var listEnumerator = collList.getEnumerator();

    while (listEnumerator.moveNext()) {
        var oList = listEnumerator.get_current();
        listInfo += 'Title: ' + oList.get_title() + ' Created: ' + oList.get_created().toString() + '\n';
    }
    alert(listInfo);
}

function onQueryFailed(sender, args) {
    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}

解决方案

Hi,

I just went through your snippet , I dont think this is going to return any result of lists items under the sub sites .. you probably you should be doing the CAML Query against multiple list abd you can scope it down to the particular subsite. 

Please have a look at the  below article .. its very well written and let me know if you have any question.

https://plumsail.com/docs/workflow-actions-pack/how-to/query%20multiple%20lists%20across%20multiple%20sites%20and%20group%20results.html


这篇关于如何查询&amp;显示子网站上所有列表中的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆