2、nt网站所有的Group //Get All The Site Groups in SharePoint Using ECMAScript var groupCollection; function getAllSiteGroups() { var clientContext = new SP.ClientContext(); this.groupCollection = clientContext.get_web().get_siteGroups(); clientContext.load(groupCol
3、lection); clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceededgetAllSiteGroups), Function.createDelegate(this, this.onQueryFailedgetAllSiteGroups)); }http://qianming.wan128.cn function onQuerySucceededgetAllSiteGroups() { var gr
4、oupName = 'Site Groups: '; var groupsEnumerator = this.groupCollection.getEnumerator(); while (groupsEnumerator.moveNext()) { var group = groupsEnumerator.get_current(); groupName += 'Title :' + group.get_title() + 'ID :' + group.get_id() + '';
5、 } alert(groupName); } function onQueryFailedgetAllSiteGroups(sender, args) { alert('Request failed. ' + args.get_message() + '' + args.get_stackTrace()); } 2、获取当前登录用户的Title与所属Group //retrieve curent loggedin user and the usres GROUP var user; v
6、ar visitorsGroup; function retrieveCurrLgUserAndGrp() { var clientContext = new SP.ClientContext(); var groupCollection = clientContext.get_web().get_siteGroups(); // Get the visitors group, assuming its ID is 4. visitorsGroup = groupCollection.getById(4)
7、; user = clientContext.get_web().get_currentUser(); var userCollection = visitorsGroup.get_users(); userCollection.addUser(user); clientContext.load(user); clientContext.load(visitorsGroup); clientContext.executeQueryAsync(Function.createDele