Sharepoint 2007: Create a multi-line text custom property for a custom field type?

别来无恙 提交于 2019-12-23 19:31:01

问题


I'm trying to extend the built-in Choice field type to include another piece of data: a correct answer. With this, users would be able to create their own tests directly within Sharepoint instead of having to use InfoPath or some other convoluted solution. I was hoping to just inherit the existing SPFieldChoice type and add one more custom property to hold an integer representing the correct answer from the choices entered.

I've got a FieldTestQuestion class that inherits from SPFieldChoice along with a pretty basic TestQuestionFieldControl class inheriting from RadioButtonChoiceField. My fldtypes_TestQuestionField.xml file:

  <FieldTypes>
    <FieldType>
        <Field Name="TypeName">TestQuestion</Field>
        <Field Name="ParentType">Choice</Field>
        <Field Name="TypeDisplayName">Test Question (Multiple choice)</Field>
        <Field Name="TypeShortDescription">Test Question (Multiple choice)</Field>
        <Field Name="UserCreatable">TRUE</Field>
        <Field Name="ShowInColumnTemplateCreate">TRUE</Field>
        <Field Name="FieldTypeClass">MyCustomFieldTypes.FieldTestQuestion,MyCustomFieldTypes, Version=1.0.0.0, Culture=neutral, PublicKeyToken=****</Field>
        <PropertySchema>
            <Fields>
                <Field Name="CorrectAnswer" DisplayName="Correct answer (line number)" Type="Integer">
                    <Default></Default>
                </Field>
            </Fields>
        </PropertySchema>
    </FieldType>
  </FieldTypes>

Unfortunately, this is what renders when I try adding a column of this type:
(source: mudman.us)

No option to add the choices as with the Choice field type:
(source: mudman.us)

What do I need to put in my fldTypes_.xml to tell Sharepoint to either (a) use the existing custom properties for the Choice column and ADD the extra property I specified or (b) specifically define a multi-line text custom property?


回答1:


It would appear the Choice input box is being created specifically for SPFieldChoice columns; one of many un-inheritable features. This means that you're unlikely to be able to persuade SharePoint to reproduce it for your custom field type.

My advice would be to go for option b), and create it yourself. I believe adding this to the <fields> element will do the trick:

<Field Name="ChoiceFix" DisplayName="Type each choice on a separate line:" Type="Note" />

Be warned that I haven't tested this solution reliability, and you may have to go down the spiky and unpleasant route of making your own Field Editor Control.



来源:https://stackoverflow.com/questions/5082936/sharepoint-2007-create-a-multi-line-text-custom-property-for-a-custom-field-typ

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!