2017-06-01 26 views

答えて

0

をjsom使用ピッカあなたは、クライアントの人々がHTMLでコントロール定義:

<div id="control" title="Users" spclientpeoplepicker="true"></div> 

次に、あなたがそれを初期化する必要があります。あなたはこれらのJavaScriptファイルがロードされていることを保証する必要があり、それを正しく初期化するために

autofill.jsclienttemplates.jsclientforms.jsclientpeoplepicker.js

JavaScriptが制御値コードを設定します。

エンティティは、機能AddUserKeys

で自動的に検証されています
var userField = $("input[id$='ClientPeoplePicker_EditorInput']").get(0); // simplified user control search, real word scenario, first search proper row in your form 
var peoplepicker = SPClientPeoplePicker.PickerObjectFromSubElement(userField); 
peoplepicker.AddUserKeys("Login1"); // or display name 
peoplepicker.AddUserKeys("Login2"); 

ジャワスクリプトのinit制御コード:

SP.SOD.loadMultiple(['autofill.js', 'clienttemplates.js', 'clientforms.js', 'clientpeoplepicker.js'], registerControls); 

function registerControls() { 
    initPeoplePicker('control'); 
} 

function initPeoplePicker (id, user) { 
    // Create a schema to store picker properties, and set the properties. 
    var schema = {}; 
    schema['PrincipalAccountType'] = 'User'; //,DL,SecGroup,SPGroup'; 
    schema['SearchPrincipalSource'] = 15; 
    schema['ResolvePrincipalSource'] = 15; 
    schema['AllowMultipleValues'] = true; 
    schema['MaximumEntitySuggestions'] = 50; 
    schema['Width'] = '311px'; 

    // use code below to init controls with selected user 
    /* 
    var users = new Array(1); 
    var defaultUser = {}; 
    defaultUser.AutoFillDisplayText = user.Value; 
    defaultUser.AutoFillKey = user.get_loginName(); 
    defaultUser.Description = user.get_email(); 
    defaultUser.DisplayText = user.get_title(); 
    defaultUser.EntityType = "User"; 
    defaultUser.IsResolved = true; 
    defaultUser.Key = user.get_loginName(); 
    defaultUser.Resolved = true; 
    users[0] = defaultUser; 
    */ 

    // Render and initialize the picker. 
    // Pass the ID of the DOM element that contains the picker, an array of initial 
    // PickerEntity objects to set the picker value, and a schema that defines 
    // picker properties. 
    SPClientPeoplePicker_InitStandaloneControlWrapper(id, null/*users*/, schema); 
} 
+0

私は人々からユーザーを取得する必要はありません。私はそれが動作thanks..hope私は私の答え –

+0

から人々ピッカーに値を設定したいピッカー – tinamou

+0

を更新したリスト –

関連する問題