2

我创建了一个包含自定义字段的列表(sharepoint 2010)。自定义字段继承自 SPFieldUser。在我创建了一个新的 ListItem (webfrontend) 并查看元素详细信息后,该字段为空。

Webfronted NewItemForm Webfronted NewItemForm Webfronted ItemDetailsForm Webfronted ItemDetailsForm Webfronted EditItemForm Webfronted EditItemForm

我的代码:

public class Vertreter_FieldType:SPFieldUser
    {
     public Vertreter_FieldType(SPFieldCollection fields, string fieldName)
           : base(fields, fieldName)
       {

       }
        public Vertreter_FieldType(SPFieldCollection fields, string typeName, string fieldName)
            : base(fields, typeName, fieldName)
        {
        }

        public override object GetFieldValue(string value)
        {
            return base.GetFieldValue(value);
        }

        public override string DefaultValue
        {
            get
            {
                return base.DefaultValue;
            }
            set
            {
                base.DefaultValue = value;
            }
        }
    }

XML 类型:

<FieldTypes>
  <FieldType>
    <Field Name="TypeName">Vertreter_FieldType</Field>
    <Field Name="ParentType">User</Field>
    <Field Name="TypeDisplayName">Vertreter</Field>
    <Field Name="TypeShortDescription">Auswahl Vertreter</Field>
    <Field Name="UserCreatable">TRUE</Field>
    <Field Name="FieldTypeClass">CustomFieldTypes.Vertreter_FieldType, $SharePoint.Project.AssemblyFullName$</Field>
  </FieldType>
</FieldTypes>

我的内容类型列表基于:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
...
<Field ID="{2C338272-3BC8-45bc-B33E-5FBD1223F398}"
         DisplayName="Administrator" Name="Administrator" 
         Type="Admin_FieldType" Required="TRUE"
         UnlimitedLengthInDocumentLibrary="FALSE"
     />
  <Field ID="{585CE72A-72D7-4ecc-8324-484BA1E483F1}"
         DisplayName="Vertreter" Name="Vertreter"
         Type="Vertreter_FieldType" Required="TRUE"
         UnlimitedLengthInDocumentLibrary="FALSE"
         >
  </Field>
...
  <FieldRefs>

...
     <FieldRef ID="{2C338272-3BC8-45bc-B33E-5FBD1223F398}" Name="Administrator" Required="TRUE" ShowInNewForm="TRUE" ShowInEditForm="TRUE" />
     <FieldRef ID="{585CE72A-72D7-4ecc-8324-484BA1E483F1}" Name="Vertreter" Required="TRUE" ShowInNewForm="TRUE" ShowInEditForm="TRUE" />
 ...

    </FieldRefs>
  </ContentType>
</Elements>

我的环境:sharepoint 2010、visualstudio 2010

谢谢你的帮助!

4

1 回答 1

1

找到解决方案:我必须将List="UserInfo"添加到 FieldDefinition。

<Field ID="{585CE72A-72D7-4ecc-8324-484BA1E483F1}" DisplayName="Vertreter" Name="Vertreter" Type="Vertreter_FieldType" Required="TRUE" UnlimitedLengthInDocumentLibrary="FALSE" List="UserInfo">
于 2012-04-26T08:14:26.100 回答