Ask a questionAsk a question
 

AnswerCustom Field for lists - property value not restored

  • Monday, November 02, 2009 3:06 PMJimmy Thomsen Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi,

    We have been developing our own custom fields and controls for SharePoint Lists. They all work fine. The problem is, that we now have the need to specify some settings for our custom controls. We made this possible by implementing a property, that the user may set when creating a new list column with the given field type. This also works great. The problem occures when the user wants to modify the column. The value set in the property is not restored (see screenshot: http://img222.imageshack.us/img222/6683/valuenotrestored.png).

    The following is a simplified version of my field definition file (fldtypes_xyz.xml):

    <?xml version="1.0" encoding="utf-8" ?>
    <FieldTypes>
      <FieldType>
        <Field Name="TypeName">CompanySelectEnum</Field>
        <Field Name="ParentType">Text</Field>
        <Field Name="TypeDisplayName">$Resources:Company,SPFields_Name_SelectEnum</Field>
        <Field Name="TypeShortDescription">$Resources:Company,SPFields_Description_SelectEnum</Field>
        <Field Name="FieldTypeClass">CompanySPControls.SPSelectEnumField, CompanySPControls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9109eca8fce563d2</Field>
        <RenderPattern Name="DisplayPattern">
          <Column HTMLEncode="TRUE" />
        </RenderPattern>
        <PropertySchema>
          <Fields>
            <Field Name="SelectEnum" DisplayName="Select Enum" Required="TRUE" DisplaySize="50" MaxLength="200" Type="Text" />
          </Fields>
        </PropertySchema>
      </FieldType>
    </FieldTypes>

    As you can see, the property is defined in the PropertySchema section. In the code behind the property is defined like this:

    public string SelectEnum
    {
        get { return (string)this.GetCustomProperty("SelectEnum"); }
        set { this.SetCustomProperty("SelectEnum", value); }
    }

    The property is indeed both saved and available. The only problem is, that the value is not displayed in the property field when editing the column based on the field.

    Any help on this topic would be greatly appriciated.

     - Thanks in advance

    Best regards
    Jimmy Thomsen

Answers

All Replies