本文介绍了如何在该分区中显示所有列表标题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<script type="text/javascript">
window.onload = function(){ ExecuteOrDelayUntilScriptLoaded(ViewItem, 'sp.js'); };
function ViewItem()
{
var ctx = new SP.ClientContext.get_current();
this.ListColl = ctx.get_web().get_lists();
ctx.load(this.ListColl);
ctx.executeQueryAsync(Function.createDelegate(this, this.onSuccess), Function.createDelegate(this, this.onFail));
}
function onSuccess(sender, args)
{
var listEnum = this.ListColl.getEnumerator();
while(listEnum.moveNext())
{
var oList = listEnum.get_current();
document.getElementById('resultpanel').innerHTML=oList.get_title();
}
}
function onFail(sender, args)
{
alert('FAIL!');
}
</script>
推荐答案
function demo()
{
var clientContext = new SP.ClientContext.get_current();
var web = clientContext.get_web();
this.lists = web.get_lists();
clientContext.load(lists);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onListItemsLoadSuccess), Function.createDelegate(this, this.onQueryFailed));
}
function onListItemsLoadSuccess(sender, args) {
var count = this.lists.get_count();
for (x = 0; x < count; x++)
{
if(this.lists.itemAt(x).get_baseType() === 1) {
var listTitle = this.lists.itemAt(x).get_title();
console.log(listTitle);
}
}
}
function onQueryFailed(sender, args) {
alert('request failed ' + args.get_message() + '\n' + args.get_stackTrace());
}
这篇关于如何在该分区中显示所有列表标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!