0

我已经使用框架创建了客户端 webpart,sharepoint以在 SPO 2013 站点中创建列表和内容类型。

元素.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>

架构.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,它会创建列表、列和内容类型,但是在将内容类型添加到列表时,它会添加一个从元素内容类型继承的内容类型,而不是直接从成本中心继承。

在此处输入图像描述

4

0 回答 0