自定义列表defenition不会将正确的内容类型添加到列表中

时间:2018-01-24 16:21:25

标签: xml sharepoint sharepoint-online list-definition sharepointframework

我创建了带有sharepoint框架的客户端webpart,以在SPO 2013网站中创建列表和内容类型。

Elements.xml的

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">

   <Field ID="{060E50AC-E9C1-4D3C-B1F9-DE0BCAC300F6}"
           Name="SPFxAmount"
           DisplayName="Amount"
           Type="Currency"
           Decimals="2"
           Min="0"
           Required="FALSE"
           Group="SPFx Columns" />

   <Field ID="{943E7530-5E2B-4C02-8259-CCD93A9ECB18}"
           Name="SPFxCostCenter"
           DisplayName="Cost Center"
           Type="Choice"
           Required="FALSE"
           Group="SPFx Columns">
       <CHOICES>
       <CHOICE>Administrgggation</CHOICE>
       <CHOICE>Informadtion</CHOICE>
       <CHOICE>Facilities</CHOICE>
       <CHOICE>Operations</CHOICE>
       <CHOICE>Sales</CHOICE>
       <CHOICE>Marketing</CHOICE>
       </CHOICES>
   </Field>

   <ContentType ID="0x010042D0C1C200A14B6887742B6344675C8B" 
           Name="Cost Center" 
           Group="SPFx Content Types" 
           Description="Sample content types from web part solution">
       <FieldRefs>
           <FieldRef ID="{060E50AC-E9C1-4D3C-B1F9-DE0BCAC300F6}" /> 
           <FieldRef ID="{943E7530-5E2B-4C02-8259-CCD93A9ECB18}" />
       </FieldRefs>
   </ContentType> 

   <ListInstance 
           CustomSchema="schema.xml"
           FeatureId="00bfea71-de22-43b2-a848-c05709900100"
           Title="SPFx List" 
           Description="SPFx List"
           TemplateType="100"
           Url="Lists/SPFxList">
   </ListInstance>

</Elements>

schema.xml中:

<List xmlns:ows="Microsoft SharePoint" Title="Basic List" EnableContentTypes="TRUE" FolderCreation="FALSE" Direction="$Resources:Direction;" Url="Lists/Basic List" BaseType="0" xmlns="http://schemas.microsoft.com/sharepoint/">
 <MetaData>
   <ContentTypes>
     <ContentTypeRef ID="0x010042D0C1C200A14B6887742B6344675C8B" />
   </ContentTypes>
   <Fields></Fields>
   <Views>
     <View BaseViewID="1" Type="HTML" WebPartZoneID="Main" DisplayName="$Resources:core,objectiv_schema_mwsidcamlidC24;" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" SetupPath="pages\viewpage.aspx" ImageUrl="/_layouts/images/generic.png" Url="AllItems.aspx">
       <XslLink Default="TRUE">main.xsl</XslLink>
       <JSLink>clienttemplates.js</JSLink>
       <RowLimit Paged="TRUE">30</RowLimit>
       <Toolbar Type="Standard" />
       <ViewFields>
         <FieldRef Name="LinkTitle"></FieldRef>
         <FieldRef Name="SPFxAmount"></FieldRef>
         <FieldRef Name="SPFxCostCenter"></FieldRef>
       </ViewFields>
       <Query>
         <OrderBy>
           <FieldRef Name="ID" />
         </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>

当我部署webPart时,它会创建列表,列和内容类型,但在将内容类型添加到列表时,它会添加一个继承自元素的内容类型内容类型,而不是直接从成本中心继承。

enter image description here

0 个答案:

没有答案