本文介绍了如何查询&显示子网站上所有列表中的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,
我希望查询并显示特定子网站上存在(并且将来会存在)的所有列表中的项目。  ;
以下是我目前的情况,但它没有产生任何警报,任何人都可以帮忙吗?
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());
}
解决方案
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());
}
解决方案
这篇关于如何查询&显示子网站上所有列表中的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!