CustomForm中的ClientPeoplePicker

时间:2014-04-14 13:51:38

标签: c# asp.net sharepoint sharepoint-2013 jscript

我有日历,并有一些客户字段,并通过自定义表单输入。由于自定义表单默认使用SharePoint:FormField for people picker;我已使用以下

包含ClientPeoplePicker
<SharePoint:ClientPeoplePicker Required="true" ValidationEnabled="true" ID="peoplepciker"  runat="server" AutoFillEnabled="True" VisibleSuggestions="3"  Rows="1" AllowMultipleEntities="false"  CssClass="ms-long ms-spellcheck-true" Height="85px" />

有人可以建议我如何将此人员的输出与日历列表中的字段相关联/绑定?

我仅使用SP_Designer2013和SharePoint客户端,并且无法以任何其他形状/形式访问后端/服务器。

非常感谢任何帮助。

谢谢

1 个答案:

答案 0 :(得分:3)

我知道这对你来说可能为时已晚,但我也在寻找答案,并认为我会分享我的解决方案。

旧控制

在我的新表单中,我有一个控件,我想用ClientPeoplePicker替换。

<SharePoint:FormField runat="server" id="ff2{$Pos}" ControlMode="New" FieldName="Person" __designer:bind="{ddwrt:DataBind('i',concat('ff2',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Person')}"/>

新控件

新的ClientPeoplePicker只需要与我想要替换的控件具有相同的id属性。

<SharePoint:ClientPeoplePicker runat="server" id="ff2{$Pos}" />

修改

我找到了一个论坛,其中列出了一些控件的属性,并认为我会发布这些属性,因为任何人应该偶然发现这个问题。

http://social.msdn.microsoft.com/Forums/en-US/1bd323bf-a009-446b-aac5-e2b9ebde1a07/sharepoint-client-people-picker-allowing-multiple-entries

<SharePoint:ClientPeoplePicker
        Required="true"
        ValidationEnabled="true"
        ID="pplPickerSiteRequestor"
        UseLocalSuggestionCache="true"
        PrincipalAccountType="User"
        runat="server"
        VisibleSuggestions="3"
        Rows="1"
        AllowMultipleEntities="false"
        CssClass="ms-long ms-spellcheck-true user-block"
        ErrorMessage="*" 
/>

<asp:CustomValidator 
        ID="cvpplSiteRequestor" 
        runat="server" 
        ControlToValidate="pplPickerSiteRequestor" 
        ForeColor="Red" 
        ClientValidationFunction="CheckSiteRequestor" 
        ErrorMessage="User is a required field"
        ValidationGroup="SiteAccessForm"
        Text="*">
</asp:CustomValidator>


function CheckSiteRequestor(sender, args) {
    args.IsValid = false;
    var userCount = $("span.ms-entity-resolved").length; //Returns the userNames Count 

    if (userCount === 1) {
        args.IsValid = true;
    }
}