本文介绍了&"getEnumerator不是函数&"Javascript(在线SharePoint)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人知道我为什么得到
在我的OnSuccess()函数中?
in my OnSuccess() function?
当我尝试获取网站集中所有列表的标题时,此代码运行良好.
This code worked fine before, when I tried to get the Titles of all lists in my site collection.
现在,我想在分配给 testIssues
的列表中获得分配给John Doe的所有行的标题.
Now I want to get the titles of all rows assigned to John Doe, in my list called testIssues
.
我错过了什么?
'use strict';
var clientContext = new SP.ClientContext.get_current();
var hostweburl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
var parentContext = new SP.AppContextSite(clientContext, hostweburl);
var parentWeb = parentContext.get_web();
var list = parentWeb.get_lists().getByTitle("testIssues");
var listItems;
$(document).ready(function () {
});
function VisaLista() {
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml("<View><Query><Where><Geq><FieldRef Name='p32c'/>" +
"<Value Type='User'>John doe</Value></Geq></Where></Query></View>");
listItems = list.getItems(camlQuery);
clientContext.load(listItems);
clientContext.executeQueryAsync(OnSuccess, OnFail);
}
function OnSuccess() {
var listString;
var listEnumerator = list.getEnumerator();
while (listEnumerator.moveNext()) {
var currentItem = listEnumerator.get_current();
listString += "<br/> " + currentItem.get_title();
}
$('#divAllaListor').html(listString);
}
function OnFail(sender, args) {
alert('Failed, Error:' + args.get_message());
}
function getQueryStringParameter(param) {
var params = document.URL.split("?")[1].split("&");
var strParams = "";
for (var i = 0; i < params.length; i = i + 1) {
var singleParam = params[i].split("=");
if (singleParam[0] == param) {
return singleParam[1];
}
}
}
推荐答案
您正在将列表项加载到名为 listItems
而不是 list
的变量中.
You're loading the list items into a variable named listItems
, not list
.
尝试 var listEnumerator = listItems.getEnumerator();
这篇关于&"getEnumerator不是函数&"Javascript(在线SharePoint)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!