Sharepoint 2007:为自定义字段类型创建多行文本自定义属性? [英] Sharepoint 2007: Create a multi-line text custom property for a custom field type?

查看:45
本文介绍了Sharepoint 2007:为自定义字段类型创建多行文本自定义属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试扩展内置的 Choice 字段类型以包含另一条数据:正确答案.有了这个,用户将能够直接在 Sharepoint 中创建自己的测试,而不必使用 InfoPath 或其他一些复杂的解决方案.我希望只是继承现有的 SPFieldChoice 类型并添加一个自定义属性来保存一个整数,该整数表示输入的选项中的正确答案.

我有一个继承自 SPFieldChoice 的 FieldTestQuestion 类以及一个继承自 RadioButtonChoiceField 的非常基本的 TestQuestionFieldControl 类.我的 fldtypes_TestQuestionField.xml 文件:

 <字段类型><Field Name="TypeName">TestQuestion</Field><Field Name="ParentType">Choice</Field><Field Name="TypeDisplayName">试题(多项选择)</Field><Field Name="TypeShortDescription">测试问题(多项选择)</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><属性架构><字段><Field Name="CorrectAnswer" DisplayName="正确答案(行号)" Type="Integer"><默认></默认></字段></字段></PropertySchema></FieldType></FieldTypes>

不幸的是,当我尝试添加这种类型的列时,呈现如下:
(来源:
(来源:mudman.us)

我需要在我的 fldTypes_.xml 中放入什么来告诉 Sharepoint (a) 使用 Choice 列的现有自定义属性并添加我指定的额外属性或 (b) 专门定义多行文本自定义财产?

解决方案

看起来 Choice 输入框是专门为 SPFieldChoice 列创建的;许多不可继承的特征之一.这意味着您不太可能说服 SharePoint 为您的自定义字段类型重现它.

我的建议是选择选项 b),然后自己创建.我相信将其添加到 元素会解决问题:

<Field Name="ChoiceFix" DisplayName="在单独的行中输入每个选项:" Type="Note"/>

请注意,我还没有测试过此解决方案的可靠性,您可能不得不走上创建自己的字段编辑器控件的尖锐和令人不快的路线.

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?

解决方案

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.

这篇关于Sharepoint 2007:为自定义字段类型创建多行文本自定义属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆