


























在此次练习中,您将利用包括Visual Studio 2010在内的SharePoint开发工具来新建一个SharePoint列表。
项目类型: 已安装的模板» SharePoint » 2010
模板: 空白SharePoint项目
名称: ListsAndSchemas




<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Field SourceID="http://schemas.microsoft.com/sharepoint/v3"
ID="{36819A9B-E748-47D5-9949-A65DD195BF80}"
Name="ProductDescription"
DisplayName="Product Description"
Group="My Custom Columns"
Type="Text"
DisplaceOnUpgrade="TRUE" />
<Field SourceID="http://schemas.microsoft.com/sharepoint/v3"
ID="{5CD2C0C1-67AC-4F9E-BF21-463CFEE9B382}"
Name="ProductID"
DisplayName="Product ID"
Group="My Custom Columns"
Type="Number"
DisplaceOnUpgrade="TRUE" />
</Elements>
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Field SourceID="http://schemas.microsoft.com/sharepoint/v3" />
<Field SourceID="http://schemas.microsoft.com/sharepoint/v3" />
<ContentType ID="0x01001586d96f1cb54a19becaf8ee2f193899"
Name="Product"
Group="我的自定义内容类型"
Description="我的Product内容类型"
Inherits="TRUE"
Version="0">
<FieldRefs>
<FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}"
Name="Title"
DisplayName="Product Name" />
<FieldRef ID="{36819A9B-E748-47D5-9949-A65DD195BF80}"
Name="ProductDescription" />
<FieldRef ID="{5CD2C0C1-67AC-4F9E-BF21-463CFEE9B382}"
Name="ProductID" />
</FieldRefs>
</ContentType>
</Elements>



<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ListTemplate
Name="ProductList"
Type="10001"
BaseType="0"
OnQuickLaunch="TRUE"
SecurityBits="11"
Sequence="410"
DisplayName="ProductList"
Description=""
Image="/_layouts/images/itgen.gif"/>
</Elements>
<?xml version="1.0" encoding="utf-8"?>
<List xmlns:ows="Microsoft SharePoint" Title="ProductList" EnableContentTypes="TRUE" FolderCreation="FALSE" Direction="$Resources:Direction;" Url="Lists/ListsAndSchemas-ProductList" BaseType="0" xmlns="http://schemas.microsoft.com/sharepoint/">
<MetaData>
<ContentTypes>
<ContentTypeRef ID="0x01">
<Folder TargetName="Item" />
</ContentTypeRef>
<ContentTypeRef ID="0x0120" />
<ContentTypeRef ID="0x01001586d96f1cb54a19becaf8ee2f193899" />
</ContentTypes>
.应确保使用与您之前所创建的内容类型相同的内容类型ID。
<?xml version="1.0" encoding="utf-8"?>
<List xmlns:ows="Microsoft SharePoint" Title="ProductList" EnableContentTypes="TRUE" FolderCreation="FALSE" Direction="$Resources:Direction;" Url="Lists/ListsAndSchemas-ProductList" BaseType="0" xmlns="http://schemas.microsoft.com/sharepoint/">
<MetaData>
<ContentTypes>…</ContentTypes>
<Fields>
<Field ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}"
Name="Title"
DisplayName="Product Name"
Type="Text" />
<Field ID="{36819A9B-E748-47D5-9949-A65DD195BF80}"
Name="ProductDescription"
DisplayName="Product Description"
Type="Text" />
<Field ID="{5CD2C0C1-67AC-4F9E-BF21-463CFEE9B382}"
Name="ProductID"
DisplayName="ProductID"
Type="Number" />
</Fields>
<ViewFields>
<FieldRef Name="LinkTitleNoMenu"></FieldRef>
<FieldRef ID="{36819A9B-E748-47D5-9949-A65DD195BF80}"
Name="ProductDescription"
DisplayName="Product Description" />
<FieldRef ID="{5CD2C0C1-67AC-4F9E-BF21-463CFEE9B382}"
Name="ProductID"
DisplayName="ProductID" />
</ViewFields>
<ViewFields>
<FieldRef Name="Attachments"></FieldRef>
<FieldRef Name="LinkTitle"></FieldRef>
<FieldRef ID="{36819A9B-E748-47D5-9949-A65DD195BF80}"
Name="ProductDescription"
DisplayName="Product Description" />
<FieldRef ID="{5CD2C0C1-67AC-4F9E-BF21-463CFEE9B382}"
Name="ProductID"
DisplayName="ProductID" />
</ViewFields>




<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ListInstance Title="Products"
OnQuickLaunch="TRUE"
TemplateType="10001"
Url="Lists/Products"
Description="">
</ListInstance>
</Elements>





在此次练习中,您已经使用Visual Studio 2010中全新的SharePoint Tools新建了若干网站栏、一个内容类型、列表模板以及该列表的一个实例。
相关文件下载03_Lists.zip
参考资料:
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。