javascript 如何使用jquery从sharepoint用户配置文件数据库中获取用户
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4866608/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to get users from sharepoint user profile db using jquery
提问by Ishaan Puniani
i just want to know: Is there any way to get a SharePoint user using JavaScript/jQuery from default sharepoint-2010 user profile DB?
我只想知道:有没有办法从默认的 sharepoint-2010 用户配置文件数据库中获取使用 JavaScript/jQuery 的 SharePoint 用户?
My requirement is to form an array of all SharePoint site users (user name) and use this array in a java function (that run behind the page at client side ) as a data source for a SPServices function.
我的要求是形成一个包含所有 SharePoint 站点用户(用户名)的数组,并在 Java 函数(在客户端页面后面运行)中使用该数组作为 SPServices 函数的数据源。
Please provide any feasible solution or any other approach for building the array for JavaScript.
请提供任何可行的解决方案或任何其他方法来为 JavaScript 构建数组。
thanks
谢谢
采纳答案by Marek Grzenkowicz
There are two ways to do it:
有两种方法可以做到:
Use client object model (OM) for ECMAScript:
- Get all users and groups client object model sharepoint 2010
SharePoint 2010: Client Object Model for JavaScript (ECMAScript)
The first article explains how to retrieve information about SharePoint users using OM and the second one shows how to use OM from JavaScript - you have to combine appropriate pieces of code.
Call appropriate method from the UserGroupservice(e.g.
GetAllUserCollectionFromWeborGetUserCollection) using jQuery:
为 ECMAScript 使用客户端对象模型 (OM):
- 获取所有用户和组客户端对象模型 sharepoint 2010
SharePoint 2010:JavaScript 客户端对象模型 (ECMAScript)
第一篇文章解释了如何使用 OM 检索有关 SharePoint 用户的信息,第二篇文章展示了如何从 JavaScript 使用 OM - 您必须组合适当的代码片段。
使用 jQuery从UserGroup服务(例如
GetAllUserCollectionFromWeb或GetUserCollection)调用适当的方法:
回答by trgraglia
Using SPServices from codeplex:
使用来自 codeplex 的 SPServices:
<script type="text/javascript">
$(document).ready (function() {
$().SPServices({
operation: "GetListItems",
async: true,
listName: "User Information List",
CAMLViewFields: "<ViewFields>" +
"<FieldRef Name='Title' />" +
"</ViewFields>",
completefunc: AttachMembersAutoComplete
});
});
function AttachMembersAutoComplete(xmlResponse) {
var domElementArray = $( "[nodeName=z:row]", xmlResponse.responseXML );
var dataMap = domElementArray.map(function() {
return {
value: $(this).attr('ows_Title'),
};
});
var data = dataMap.get();
$("input#inputMembersAutoComplete").autocomplete({
source: data,
select: function(e, ui){
var tmpHTML = ui.item['value'];
$("#person_info").html(tmpHTML);
}
});
}
</script>

