Sharepoint JSCOM 列表操作
2021-07-12 11:05
标签:rand cut 官方文档 官方 cli log doc point ima /**这里需要注意!对于某些属性有自带的获取方法,比如:get_id(),get_title(); 要查看列表字段的名称(Title)和对应的内部名称(InternalName),可以参考官方文档: 参考:https://msdn.microsoft.com/zh-cn/library/office/jj163201.aspx Sharepoint JSCOM 列表操作 标签:rand cut 官方文档 官方 cli log doc point ima 原文地址:http://www.cnblogs.com/lishidefengchen/p/7082294.html SP.SOD.executeFunc(‘sp.js‘, ‘SP.ClientContext‘, retrieveListItemsInclude); //确保js文件加载,再执行方法
function retrieveListItemsInclude() {
var clientContext = new SP.ClientContext.get_current();
var oList = clientContext.get_web().get_lists().getByTitle(‘背景图片‘);
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml(‘
//成功回调函数
function onQuerySucceeded(sender, args) {
this.BackgroundImg = [];
var listItemEnumerator = collListItem.getEnumerator();
while (listItemEnumerator.moveNext()) {
var oListItem = listItemEnumerator.get_current();
*但对于大多数的属性都必须使用get_item("属性名")来获取值,
**/而且”属性名“要跟 Include("属性名")中的属性名保持大小写一致!!
//失败回调函数
function onQueryFailed(sender, args) {
alert(‘Request failed. ‘ + args.get_message() +
‘\n‘ + args.get_stackTrace());
}function retrieveAllListsAllFields(siteUrl) {
var clientContext = new SP.ClientContext(siteUrl);
var oWebsite = clientContext.get_web();
var collList = oWebsite.get_lists();
this.listInfoArray = clientContext.loadQuery(collList,
‘Include(Title,Fields.Include(Title,InternalName))‘);
clientContext.executeQueryAsync(
Function.createDelegate(this, this.onQuerySucceeded),
Function.createDelegate(this, this._onQueryFailed)
);
}
function onQuerySucceeded() {
var listInfo = ‘‘;
for (var i = 0; i this.listInfoArray.length; i++) {
var oList = this.listInfoArray[i];
var collField = oList.get_fields();
var fieldEnumerator = collField.getEnumerator();
while (fieldEnumerator.moveNext()) {
var oField = fieldEnumerator.get_current();
var regEx = new RegExp(‘name‘, ‘ig‘);
if (regEx.test(oField.get_internalName())) {
listInfo += ‘\nList: ‘ + oList.get_title() +
‘\n\tField Title: ‘ + oField.get_title() +
‘\n\tField Name: ‘ + oField.get_internalName();
}
}
}
alert(listInfo);
}
function onQueryFailed(sender, args) {
alert(‘Request failed. ‘ + args.get_message() +
‘\n‘ + args.get_stackTrace());
}
文章标题:Sharepoint JSCOM 列表操作
文章链接:http://soscw.com/index.php/essay/104131.html