代码之家  ›  专栏  ›  技术社区  ›  Janis Veinbergs

自定义列表定义+自定义内容类型=仅显示一个表单字段?

  •  4
  • Janis Veinbergs  · 技术社区  · 15 年前

    尝试使用功能部署自定义字段、内容类型和列表。到目前为止,我有一个引用自定义和内置字段的内容类型。内容类型继承项(0x01)。

    现在,我创建了引用内容类型和字段(内置和自定义)的自定义列表定义。我显式地设置 ShowInDisplayForm, ShowInEditForm, ShowInNewForm Title 各种形式的领域!

    但是,如果我将UI中的字段添加到列表中,它将显示在表单中!此外,如果我从UI创建自定义列表并添加内容类型,这些字段将显示在表单中!

    怎么回事?

    顺便说一下,我使用了VisualStudio的VSEWS工具,所以它已经正确地生成了很多东西。

    一些代码:

    <ContentTypes>
      <ContentTypeRef ID="0x01003420C661289843dbAB9E41F43C23BFD0" />
    </ContentTypes>
    <Fields>
      <Field ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" Group="$Resources:core,Extended_Columns" Required="TRUE" ShowInDisplayForm="TRUE" ShowInEditForm="TRUE" ShowInNewForm="TRUE" Type="Text" Sortable="TRUE" Filterable="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" />
      <Field ID="{B4629012-C672-4911-B0D0-B9CB2DA44ED2}" DisplayName="Jautājumu pacēla" Group="$Resources:core,Extended_Columns" Name="QuestionRisedBy" Required="TRUE" ShowInDisplayForm="TRUE" ShowInEditForm="TRUE" ShowInNewForm="TRUE" Type="User" Sortable="TRUE" Filterable="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" />
      <Field ID="{6DF9BD52-550E-4a30-BC31-A4366832A87F}" DisplayName="Komentārs" Group="$Resources:core,Extended_Columns" Name="Comment" AppendOnly="TRUE" Required="FALSE" NumLines="12" Type="Note" ShowInDisplayForm="TRUE" ShowInEditForm="TRUE" ShowInNewForm="TRUE" Sortable="FALSE" Filterable="FALSE" SourceID="http://schemas.microsoft.com/sharepoint/v3" />
      <Field ID="{FC072586-E8BB-444f-AAA4-8D5745FBC096}" DisplayName="ParentItemId" Group="$Resources:core,Extended_Columns" Name="AgendaParentItemId" Required="TRUE" Type="Integer" Sortable="FALSE" Filterable="FALSE" SourceID="http://schemas.microsoft.com/sharepoint/v3" />
      <Field ID="{29207E42-E107-4379-B620-BAAFC461276B}" DisplayName="AgendaRootItemId" Group="$Resources:core,Extended_Columns" Name="AgendaRootItemId" Required="TRUE" Type="Integer" Sortable="FALSE" Filterable="FALSE" SourceID="http://schemas.microsoft.com/sharepoint/v3" />
      <Field ID="{06063FDB-3C2A-4141-91F7-28C2739CE6B5}" DisplayName="AgendaItemClosed" Group="$Resources:core,Extended_Columns" Name="AgendaItemClosed" Required="FALSE" Type="Boolean" Sortable="TRUE" Filterable="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" />
    </Fields>
    
    1 回复  |  直到 15 年前
        1
  •  4
  •   Janis Veinbergs    15 年前

    是的,ContentType对所有字段都有FieldRef(当然,不是继承的字段)。但是我读到在schema.xml中定义contet类型时, you must explicitly define Field`s also (这很奇怪),然而

    Quite from SharePoint blog :

    完全相同的元素 类型,包括相同的ID。这是一个 要定义两次字段,请在 schema.xml中的内容类型和 让这一切顺利进行。你可以跳过 组和其他一些属性。

    但是,如果我不使用字段,我会得到一个异常:

    [COMException (0x80004005): Nevar pabeigt šo darbību.
    
    Lūdzu, mēģiniet vēlreiz.]
       Microsoft.SharePoint.Library.SPRequestInternalClass.GetViewsSchemaXml(String bstrUrl, String bstrListName, Boolean bFullBlown, ISP2DSafeArrayWriter p2DWriter, Int32& plDefaultViewIndex) +0
       Microsoft.SharePoint.Library.SPRequest.GetViewsSchemaXml(String bstrUrl, String bstrListName, Boolean bFullBlown, ISP2DSafeArrayWriter p2DWriter, Int32& plDefaultViewIndex) +122