SharePoint 字段未显示在显示/编辑/新页面中

发布于 2024-08-13 06:50:24 字数 2220 浏览 2 评论 0原文

我已经为列表编写了一个架构,只需向默认自定义列表添加一列,该列表是一个名为“月份”的数字字段。该字段显示在默认视图中,并且确实在列表中创建。该列表会自动填充正确设置的值。问题是该字段没有出现在显示/编辑/新页面上。可以通过数据表视图进行设置。我不明白为什么当我在架构中专门将其设置为时它没有显示。

非常感谢任何建议。

<?xml version="1.0" encoding="utf-8"?>
<List xmlns:ows="Microsoft SharePoint" 
      Title="ReviewPeriods" 
      FolderCreation="FALSE" 
      Direction="$Resources:Direction;" 
      Url="Lists/ReviewPeriods" 
      EnableContentTypes="TRUE" 
      BaseType="0">
 <MetaData>
  <ContentTypes>
   <ContentTypeRef ID="0x01">
        <Folder TargetName="Item" />
      </ContentTypeRef>
  </ContentTypes>
  <Fields>
   <Field ID="{B99EB797-4057-4a75-90BF-B40D0F89A9D9}"
             Type="Number"
             Decimals="0"
             Min="0"
             Max="100"
             Percentage="FALSE"
             Name="Months" 
             Required="TRUE"
             Group="SEED"
             DisplayName="Months"
             StaticName="Months"
             ShowInDisplayForm="TRUE"
             ShowInEditForm="TRUE"
             ShowInNewForm="TRUE">
   </Field>
  </Fields>
  <Views>   
   <View BaseViewID="0" 
            Type="HTML"
            WebPartZoneID="Main" 
            DisplayName="Default View" 
            DefaultView="TRUE" 
            SetupPath="pages\viewpage.aspx" 
            ImageUrl="/_layouts/images/generic.png" 
            Url="AllItems.aspx">

...隐藏的东西...

<ViewFields>
          <FieldRef Name="LinkTitle"></FieldRef>
          <FieldRef Name="Months"></FieldRef>
    </ViewFields>
    <Query>
     <OrderBy>
      <FieldRef Name="Title">
      </FieldRef>
     </OrderBy>
    </Query>
   </View>
  </Views>
  <Forms>
   <Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
   <Form Type="EditForm" Url="EditForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
   <Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
  </Forms>
 </MetaData>
</List>

I've written a schema for a list that only needs to add one column to the default custom list which is a number field called months. The field is shown on the default view and is indeed created on the list. The list is autopopulated with values which get set properly. The problem is that the field doesn't appear on the display/edit/new pages. It can be set through the datasheet view. I don't understand why it isn't showing up when I specifically set it to in the schema.

Would very much appriciate any suggestions.

<?xml version="1.0" encoding="utf-8"?>
<List xmlns:ows="Microsoft SharePoint" 
      Title="ReviewPeriods" 
      FolderCreation="FALSE" 
      Direction="$Resources:Direction;" 
      Url="Lists/ReviewPeriods" 
      EnableContentTypes="TRUE" 
      BaseType="0">
 <MetaData>
  <ContentTypes>
   <ContentTypeRef ID="0x01">
        <Folder TargetName="Item" />
      </ContentTypeRef>
  </ContentTypes>
  <Fields>
   <Field ID="{B99EB797-4057-4a75-90BF-B40D0F89A9D9}"
             Type="Number"
             Decimals="0"
             Min="0"
             Max="100"
             Percentage="FALSE"
             Name="Months" 
             Required="TRUE"
             Group="SEED"
             DisplayName="Months"
             StaticName="Months"
             ShowInDisplayForm="TRUE"
             ShowInEditForm="TRUE"
             ShowInNewForm="TRUE">
   </Field>
  </Fields>
  <Views>   
   <View BaseViewID="0" 
            Type="HTML"
            WebPartZoneID="Main" 
            DisplayName="Default View" 
            DefaultView="TRUE" 
            SetupPath="pages\viewpage.aspx" 
            ImageUrl="/_layouts/images/generic.png" 
            Url="AllItems.aspx">

... Hidden Stuff ...

<ViewFields>
          <FieldRef Name="LinkTitle"></FieldRef>
          <FieldRef Name="Months"></FieldRef>
    </ViewFields>
    <Query>
     <OrderBy>
      <FieldRef Name="Title">
      </FieldRef>
     </OrderBy>
    </Query>
   </View>
  </Views>
  <Forms>
   <Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
   <Form Type="EditForm" Url="EditForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
   <Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
  </Forms>
 </MetaData>
</List>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

听你说爱我 2024-08-20 06:50:24

问题是您将该字段添加到列表中,但同时启用内容类型并指定要使用的唯一内容类型是不包含该字段的项目 (0x01)。因此,您正在添加/编辑项目,然后您没有获得该字段。

有两种解决方案:

  1. 不启用内容类型(然后
    也删除整个
    <内容类型>部分)
  2. 创建一个新的内容类型,包括
    字段并添加该内容类型
    而不是项目

The problem is that you add the field to the list, but at the same time enable content types and specify that the only content type to use is Item (0x01) which doesn't include the field. So you're adding/editing Items and then you don't get the field.

There are two solutions:

  1. Don't enable content types (and then
    also remove the whole
    <ContentTypes> section)
  2. Create a new content type including
    the field and add that content type
    instead of Item
落日海湾 2024-08-20 06:50:24

我已经找到了解决我自己问题的方法。该字段不会在“新建/显示/编辑”表单中列出,因为这些页面基于内容类型。在本例中,我的列表所基于的项目内容类型。

通常我会创建自己的内容类型,但我一直在尝试找到一种快捷方式来创建列表,而无需定义全新的内容类型。因此,我所做的就是直接在列表架构内定义字段,而不是引用内容类型内已存在的字段。仅仅为只有一个额外字段的单次使用查找列表定义内容类型似乎有点愚蠢。

如果有人可以建议一种方法来让字段显示在“新建/显示/编辑”表单上,而无需创建新的内容类型,那么我将很乐意将它们作为接受的答案。

I've sort of found the solution to my own problem. The field doesn't get listed in the New/Display/Edit forms because those pages are based on the content type. In this case the Item content type that I base my list on.

Usually I create my own content type but I've been trying to find a shorthand way to create a list without defining a whole new content type. So what I've done is define the field directly inside the list schema rather than reference an already existing field that's within the content type. It does seem a little silly to define a content type just for a single use lookup list with only one extra field.

If someone can suggest a way to get the fields to show on the New/Display/Edit forms without having to create a new content type then I will happily make them the accepted answer instead.

海螺姑娘 2024-08-20 06:50:24

正如您所做的那样,我正在做同样的事情(为我想创建的每个列表创建内容类型)
直到我点击下面的代码。如果您查看下面的代码,我已删除 标记,并强制添加标题字段和额外的字段说明。

<Fields>
  <Field ID="{9830F5FC-99E0-4052-9CC0-50CBEDE80002}" Type="Text" Name="Title" DisplayName="Type Name" Required="TRUE" MaxLength="255" Version="1" RowOrdinal="0">
    <Default/>
  </Field>      
  <Field Type="Note" DisplayName="Description" Required="FALSE" NumLines="6" RichText="TRUE" RichTextMode="Compatible" Sortable="FALSE" 
         ID="{63C25492-BA98-4096-A6D7-F85885E0A425}" Name="Description"
          RowOrdinal="0"/>
</Fields>

......隐藏

每个答案是正确的+1

As you did I was doing the same thing (Creating Content Type for each of the List I wanted to create)
Until I hit the below code. If you look at the below code I have removed the <ContentTypes> tag and forcibly added the Title Field and the extra field Description.

<Fields>
  <Field ID="{9830F5FC-99E0-4052-9CC0-50CBEDE80002}" Type="Text" Name="Title" DisplayName="Type Name" Required="TRUE" MaxLength="255" Version="1" RowOrdinal="0">
    <Default/>
  </Field>      
  <Field Type="Note" DisplayName="Description" Required="FALSE" NumLines="6" RichText="TRUE" RichTextMode="Compatible" Sortable="FALSE" 
         ID="{63C25492-BA98-4096-A6D7-F85885E0A425}" Name="Description"
          RowOrdinal="0"/>
</Fields>

......Hidden

<MetaData>

Per Answer was Right +1

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文