SharePoint 2010:RemoveFieldRef 和 Inherits=“TRUE" [英] SharePoint 2010: RemoveFieldRef and Inherits="TRUE"

查看:62
本文介绍了SharePoint 2010:RemoveFieldRef 和 Inherits=“TRUE"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个从 OOTB SharePoint 图片 内容类型继承的自定义内容类型.我所做的唯一自定义是添加一个简单的 URL 字段,并删除基本类型上的两个字段.见下文:

I have created a custom content type that inherits from the OOTB SharePoint Picture content type. The only customisations I have made is to add a simple URL field, and remove two of the fields on the base type. See below:

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <!-- Parent ContentType: Picture (0x010102) -->
    <ContentType ID="0x0101020027f16ab27e6e45a6848c25c47aaa7053"
                 Name="Custom Picture"
                 Description=""
                 Group="Custom"
                 Inherits="TRUE"
                 Version="0">
        <FieldRefs>
            <RemoveFieldRef ID="{b66e9b50-a28e-469b-b1a0-af0e45486874}" Name="Keywords" />
            <RemoveFieldRef ID="{a5d2f824-bc53-422e-87fd-765939d863a5}"  Name="ImageCreateDate" />
            <FieldRef ID="{c29e077d-f466-4d8e-8bbe-72b66c5f205c}" Name="URL" DisplayName="URL" Required="FALSE" />
        </FieldRefs>
    </ContentType>
</Elements>

如果我根据我的自定义内容类型创建图片库,我添加的URL"字段会出现在新建/编辑表单中,但是我尝试删除的两个字段也会显示,即 RemoveFieldRef 被忽略.如果我查看站点设置 -> 内容类型库" 中的内容类型,这两个字段仍然列在那里.

If I create a picture library based on my custom content type, the "URL" field that I added appears in the new/edit forms, however the two fields that I have attempted to remove are also displayed, i.e. the RemoveFieldRef's are being ignored. If I look at the content type in "Site Settings -> Content Type Gallery", these two fields are still listed there.

在我的自定义内容类型上设置 Inherits="FALSE" (查看 MSDN 定义) 成功地从站点设置 -> 内容类型库"页面中删除了仅这两个字段,但是没有 的基本字段显示在新的/编辑表单中——只有我的自定义URL"字段.

Setting Inherits="FALSE" on my custom content type (see MSDN definition) successfully removes just these two fields from the "Site Settings -> Content Type Gallery" page, however then none of the base fields are displayed in the new/edit forms -- only my custom "URL" field.

除了我明确删除的两个字段外,如何确保基本图片"内容类型的所有字段都显示在我的图片库的新/编辑表单上?

What can I do to ensure that all the fields from the base "Picture" content type are displayed on the new/edit forms of my picture library except the two fields that I have specifically removed?

推荐答案

我认为这个问题的本质在于理解内容类型继承是如何工作的.

I believe the nature of this issue to be the understanding of how content type inheritance works.

来自 MSDN (http://msdn.microsoft.com/en-我们/图书馆/aa544268.aspx)

如果 Inherits 为 TRUE,则子内容类型继承父项中的所有字段,> 包括用户添加的字段.

If Inherits is TRUE, the child content type inherits all fields that are in the parent, >including fields that users have added.

如果 Inherits 为 FALSE 或不存在,并且父内容类型是内置类型,则子 >内容类型仅继承安装 >SharePoint Foundation 时父内容类型中的字段.子内容类型没有任何 >用户添加到父内容类型的字段.

If Inherits is FALSE or absent and the parent content type is a built-in type, the child >content type inherits only the fields that were in the parent content type when >SharePoint Foundation was installed. The child content type does not have any fields that >users have added to the parent content type.

如果 Inherits 为 FALSE 或不存在,并且父内容类型由沙盒解决方案提供,则子项不会从父项继承任何字段.

If Inherits is FALSE or absent and the parent content type was provisioned by a sandboxed >solution, the child does not inherit any fields from the parent.

我认为上面的关键短语是如果 Inherits 为 TRUE,子内容类型将继承父项中的所有字段,包括用户添加的字段."

I think the key phrase above is "If Inherits is TRUE, the child content type inherits ALL fields that are in the parent including fields that users have added."

这意味着,为了完成您打算做的事情,您将继承设置为 false,并且您必须为您希望在内容类型中使用的所有字段包含 FieldRef 元素.

This means that in order to accomplish what you set out to do you will have inherits set to false and you will have to include FieldRef elements for all fields you wish to use in your content type.

您没有参考/没有包含有关如何将内容类型添加到您的列表实例的代码.确保这已更新以支持删除或将继承设置为 false.

You make no reference / don't include code for how the content type was added to your list instance. Make sure this has been updated to support the removal or setting of inherits to false.

这些网站支持此处描述的内容.

These sites support what is described here.

http://nelsonlamprecht.wordpress.com/2010/08/25/sharepoint-2010-removefieldref-and-inherits%E2%80%9Dtrue%E2%80%9D/

这篇关于SharePoint 2010:RemoveFieldRef 和 Inherits=“TRUE"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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