1.sharepoint列表定义

本文详细介绍了如何在SharePoint中创建自定义列表定义的过程,包括建立解决方案、项目配置、XML文件编辑等内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

我习惯将列表定义单独放大一个project里。

1.建一个sharepoint solution名为sharepointtest。

2.然后再解决方案里建一个List Definition 类型的sharepoint项目,取名为SharepointTest.Lists。

3.在SharepointTest.Lists中新建一个List Definition,取名为ListDefinitionTest。列表定义类型选择自定义列表,选择添加列表实例。如图1

图1

4.打开ListDefinetionTest下的Elements.xml(不是ListInstance1下的xml),改为如下情形

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <!-- Do not change the value of the Name attribute below. If it does not match the folder name of the List Definition project item, an error will occur when the project is run. -->
    <ListTemplate
        Name="ListDefinitionTest"
        Type="10040"
        BaseType="0"
        OnQuickLaunch="TRUE"
        SecurityBits="11"
        Sequence="410"
        DisplayName="ListDefineTest"
        Description="My List Definition"
        Image="/_layouts/images/itgen.png"/>
</Elements>

注意Type的值不要重复。

5.打开ListInstance1下的 Elements.xml,改为如下情形

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <ListInstance Title="测试列表"
                OnQuickLaunch="TRUE"
                TemplateType="10040"
                Url="Lists/SharepointTest"
                Description="这是我的测试列表">
  </ListInstance>
</Elements>

注意TemplateType的值要同上文中的相同

6.打开schemal.xml,在<Fields></Fields>添加栏定义,如下文

<Field ID="{57C67E26-6122-40EC-945C-D0E14CCDC2E1}" Name="Title" DisplayName="标题" Required="FALSE" Type="Text" StaticName="Title" />
      <Field ID="{57C67E26-6122-40EC-945C-D0E14CCDC2E2}" Name="LinkTitleNoMenu" DisplayName="标题" ReadOnly="TRUE" Type="Computed" Dir="" DisplayNameSrcField="Title" AuthoringInfo="(链接到项目)" EnableLookup="TRUE" ListItemMenuAllowed="Prohibited" LinkToItemAllowed="Prohibited" StaticName="LinkTitleNoMenu" />
      <Field ID="{57C67E26-6122-40EC-945C-D0E14CCDC2E3}" Name="LinkTitle" DisplayName="标题" ReadOnly="TRUE" Type="Computed" DisplayNameSrcField="Title" ClassInfo="Menu" AuthoringInfo="(链接到带编辑菜单的项目)" ListItemMenuAllowed="Required" LinkToItemAllowed="Prohibited" StaticName="LinkTitle" />
<Field ID="{57C67E26-6122-40EC-945C-D0E14CCDC2E4}" Name="Test" DisplayName ="测试栏" Type="Text" />
<Field ID="{47539D90-EB9B-45A5-8591-68077530FD92}" Name="Field_TaxonomyDemo" StaticName="Field_TaxonomyDemo" DisplayName="TaxonomyDemo" Required="FALSE" Group="Custom group" Type="TaxonomyFieldType">
        <Customization>
          <ArrayOfProperty>
            <Property>
              <Name>TextField</Name>
              <Value xmlns:q6="http://www.w3.org/2001/XMLSchema" p4:type="q6:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">{78FF1668-CDDB-4645-8BED-FC2179944F5F}</Value>
            </Property>
          </ArrayOfProperty>
        </Customization>
   </Field>
   <Field ID="{78FF1668-CDDB-4645-8BED-FC2179944F5F}" Name="Field_TaxonomyDemoTaxHTField0" Type="Note" DisplayName="TaxonomyDemoTaxHTField0" StaticName="Field_TaxonomyDemoTaxHTField0" ShowInViewForms="FALSE" Required="FALSE" Hidden="TRUE" CanToggleHidden="TRUE"/>
   <Field ID="{971BA7B5-48EF-40D5-B863-59A93BF4EBF4}" Name="Category" DisplayName ="分类" Type="Lookup"  List="Lists/BusinessCategoryList" />
   <Field ID="{971BA7B5-48EF-40D5-B863-59A93BF4EBF5}" Name="Categorys" DisplayName ="多重分类" Type="LookupMulti"  List="Lists/BusinessCategoryList" Mult="TRUE" ShowField="Title"/>

 

 

 

7.将<ContentType></ContentType>节点改为如下情形

      <ContentType ID="0x01002EF9586416114FC28896F05C3A2DA447" Name="测试列表" Group="列表" Description="列表" Version="0">

        <FieldRefs>
          <FieldRef ID="{57C67E26-6122-40EC-945C-D0E14CCDC2E1}" Name="Title"/>
          <FieldRef ID="{57C67E26-6122-40EC-945C-D0E14CCDC2E2}" Name="LinkTitleNoMenu" />
          <FieldRef ID="{57C67E26-6122-40EC-945C-D0E14CCDC2E3}" Name="LinkTitle" />
          <FieldRef ID="{57C67E26-6122-40EC-945C-D0E14CCDC2E4}" Name="Test" />
        </FieldRefs>
      </ContentType>

8.在 <View BaseViewID="1" .......

         <ViewFields ....节点下添加节点

          <FieldRef Name="Test"></FieldRef>

9.<List></List>节点的Url属性改为Lists/SharepointTest

10.好了,可以直接部署了,部署成功以后可以看到列表了。

 

转载于:https://www.cnblogs.com/Percy/p/4167684.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值