SharePoint 2013开发入门探索(一)- 自定义列表
2014-04-03 21:09
441 查看
在SharePoint 2013中创建自定义列表的方式有很多,在网站内容页面添加应用程序就可以创建(站点内容-〉 您的应用程序),也可以通过SharePoint Designer 2013创建,而本文将描述的是用Visual Studio 2012 创建自定义列表的内容,因笔者水平有限,如果各位专家高手发现任何疏漏和错误,望不惜赐教!
首先确认您已经准备好了SharePoint环境,并且安装了Visual Studio的插件(没有插件请参考http://yalla.itgroove.net/2012/08/sharepoint-2013-project-templates-for-visual-studio-2012/)。然后打开Visual Studio-〉新建项目选择Office/SharePoint->SharePoint解决方案->SharePoint 2013-空项目,这里名称、位置可以修改。项目的名字就是发布后生成wsp文件的名字, 所以为项目取个友好的名字吧。
View Code
开发已经完成了了,现在用Visual Studio将项目部署,进入网站已经能看到我的客户列表。
再选择Visual Studio发布,生成了一个.wsp的文件-SharePointProject1.wsp(SharePointProject1是项目名),这个文件就可以拿到生产环境部署了。
最后出于好奇,我把wsp文件解压缩,看看里面是什么(如果您的机器上的压缩软件不能直接解压,可尝试修改后缀名为cab。)。我看到的首先是一个清单文件(manifest.xml),一个DLL文件(SharePointProject1.dll),还有一个功能文件夹。打开清单文件看到里面有项目属性的信息,DLL文件和功能文件夹位置等;反编译DLL文件,看到的主要是程序集信息,因为这个项目没写什么C#代码,这里内容非常少。接着再打开功能文件夹,看到的是功能清单文件(Feature.xml),列表模版文件夹(MyCustomerList)、列表实例文件夹(MyCustomerList)。功能清单文件里有功能的属性信息、列表模版和列表实例的元素位置。列表模版和列表实例文件夹里都装着各自的元素文件(Elements.xml),其中列表模板文件夹里还有个Schema.xml文件,我们开发的东西都找到了!
参考资料:
1、《在 SharePoint 2010 中创建自定义列表定义》
http://msdn.microsoft.com/zh-cn/library/ff728096(v=office.14).aspx
2、《创建 SharePoint 的网站栏、内容类型和列表》
http://msdn.microsoft.com/zh-cn/library/vstudio/ee231593(v=vs.110).aspx
3、《创建自定义字段类型》
http://msdn.microsoft.com/zh-cn/library/bb862248(office.14).aspx
微软Web平台安装器下载:
http://www.microsoft.com/web/downloads/platform.aspx
首先确认您已经准备好了SharePoint环境,并且安装了Visual Studio的插件(没有插件请参考http://yalla.itgroove.net/2012/08/sharepoint-2013-project-templates-for-visual-studio-2012/)。然后打开Visual Studio-〉新建项目选择Office/SharePoint->SharePoint解决方案->SharePoint 2013-空项目,这里名称、位置可以修改。项目的名字就是发布后生成wsp文件的名字, 所以为项目取个友好的名字吧。
<?xml version="1.0" encoding="utf-8"?> <List xmlns:ows="Microsoft SharePoint" Title="MyCustomerList" FolderCreation="FALSE" Direction="$Resources:Direction;" Url="Lists/MyCustomerList" BaseType="0" xmlns="http://schemas.microsoft.com/sharepoint/" EnableContentTypes="TRUE"> <MetaData> <ContentTypes> <ContentType ID="0x010047da51229e2f4910b4b04d43ef226aa5" Name="ListFieldsContentType"><FieldRefs><FieldRef ID="{092f3bfe-9a30-4d02-bc2f-aa9259caf21c}" Name="CustomerName" /><FieldRef ID="{23550288-91B5-4e7f-81F9-1A92661C4838}" Name="Gender" /><FieldRef ID="{fce16b4c-fe53-4793-aaab-b4892e736d15}" Name="EMail" /><FieldRef ID="{2a464df1-44c1-4851-949d-fcd270f0ccf2}" Name="CellPhone" /><FieldRef ID="{fc2e188e-ba91-48c9-9dd3-16431afddd50}" Name="WorkAddress" /><FieldRef ID="{01cdb1e0-9bc5-442a-8d77-d25e42b0efa5}" Name="Recency" /><FieldRef ID="{bdcf18e5-1b72-4bc7-afc8-76c29e6385b3}" Name="Frequency" /><FieldRef ID="{a943ca8c-a2ad-4a90-8a78-2f6a202f6553}" Name="Monetary" /><FieldRef ID="{c55677bb-5f33-46b9-a51b-4cc7337c295f}" Name="BusinessPage" /><FieldRef ID="{c45e594b-7351-473a-b71c-7c1c52e08df0}" Name="CustomerType" /><FieldRef ID="{277df47f-398c-4049-987b-66520fd77f8a}" Name="Owner" /><FieldRef ID="{284fece0-ca30-4d55-8b37-fad83f509b70}" Name="Sharers" /></FieldRefs></ContentType><ContentTypeRef ID="0x0120" /><ContentTypeRef ID="0x01"> <Folder TargetName="Item" /> </ContentTypeRef></ContentTypes> <Fields> <Field Name="CustomerName" ID="{092f3bfe-9a30-4d02-bc2f-aa9259caf21c}" DisplayName="客户姓名" Type="Text" /><Field ID="{23550288-91B5-4e7f-81F9-1A92661C4838}" Name="Gender" StaticName="Gender" SourceID="http://schemas.microsoft.com/sharepoint/v3" DisplayName="$Resources:core,Gender_OL;" Group="$Resources:core,Person_Event_Columns;" Type="Choice" Sealed="TRUE" AllowDeletion="TRUE"><CHOICES><CHOICE>$Resources:core,Male;</CHOICE><CHOICE>$Resources:core,Female;</CHOICE></CHOICES></Field><Field ID="{fce16b4c-fe53-4793-aaab-b4892e736d15}" Name="EMail" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="EMail" Group="$Resources:core,Person_Event_Columns;" DisplayName="$Resources:core,E-Mail;" ReadOnly="FALSE" Type="Text" FromBaseType="TRUE" AllowDeletion="TRUE" /><Field ID="{2a464df1-44c1-4851-949d-fcd270f0ccf2}" Name="CellPhone" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="CellPhone" Group="$Resources:core,Person_Event_Columns;" DisplayName="$Resources:core,Mobile_Phone;" Type="Text" IMEMode="inactive" Required="TRUE" /><Field ID="{fc2e188e-ba91-48c9-9dd3-16431afddd50}" Name="WorkAddress" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="WorkAddress" Group="$Resources:core,Person_Event_Columns;" DisplayName="$Resources:core,Address;" Type="Note" NumLines="2" Sortable="FALSE" Required="TRUE" /><Field Name="Recency" ID="{01cdb1e0-9bc5-442a-8d77-d25e42b0efa5}" DisplayName="最近消费时间" Type="DateTime" Format="DateOnly" /><Field Name="Frequency" ID="{bdcf18e5-1b72-4bc7-afc8-76c29e6385b3}" DisplayName="消费频率" Type="Number" Decimals="2" Max="1" Min="0" Percentage="TRUE" /><Field Name="Monetary" ID="{a943ca8c-a2ad-4a90-8a78-2f6a202f6553}" DisplayName="消费金额" Type="Currency" /><Field Name="BusinessPage" ID="{c55677bb-5f33-46b9-a51b-4cc7337c295f}" DisplayName="业务系统链接" Type="URL" Required="TRUE" /><Field Name="CustomerType" ID="{c45e594b-7351-473a-b71c-7c1c52e08df0}" DisplayName="客户类型" Type="Choice" Required="TRUE" List="Lists/CustomerTypeList" ShowField="Title"><CHOICES><CHOICE>钻石</CHOICE><CHOICE>白金</CHOICE><CHOICE>黄金</CHOICE><CHOICE>白银</CHOICE><CHOICE>青铜</CHOICE><CHOICE>精钢</CHOICE><CHOICE>垃圾</CHOICE></CHOICES></Field><Field Name="Owner" ID="{277df47f-398c-4049-987b-66520fd77f8a}" DisplayName="所有者" Type="User" Required="TRUE" UserSelectionMode="PeopleOnly" /><Field Name="Sharers" ID="{284fece0-ca30-4d55-8b37-fad83f509b70}" DisplayName="分享者" Type="UserMulti" Required="TRUE" Mult="TRUE" /></Fields> <Views> <View BaseViewID="0" Type="HTML" MobileView="TRUE" TabularView="FALSE"> <Toolbar Type="Standard" /> <XslLink Default="TRUE">main.xsl</XslLink> <RowLimit Paged="TRUE">30</RowLimit> <ViewFields> <FieldRef Name="LinkTitleNoMenu"></FieldRef></ViewFields> <Query> <OrderBy> <FieldRef Name="Modified" Ascending="FALSE"></FieldRef></OrderBy> </Query> <ParameterBindings> <ParameterBinding Name="AddNewAnnouncement" Location="Resource(wss,addnewitem)" /> <ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" /> <ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_ONET_HOME)" /> </ParameterBindings> </View><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/15/images/generic.png?rev=23" Url="AllItems.aspx"> <Toolbar Type="Standard" /> <XslLink Default="TRUE">main.xsl</XslLink> <JSLink>clienttemplates.js</JSLink> <RowLimit Paged="TRUE">30</RowLimit> <ViewFields> <FieldRef Name="LinkTitle"></FieldRef><FieldRef Name="CustomerName" /><FieldRef Name="Gender" /><FieldRef Name="EMail" /><FieldRef Name="CellPhone" /><FieldRef Name="WorkAddress" /><FieldRef Name="Recency" /><FieldRef Name="Frequency" /><FieldRef Name="Monetary" /><FieldRef Name="BusinessPage" /><FieldRef Name="CustomerType" /><FieldRef Name="Owner" /><FieldRef Name="Sharers" /></ViewFields> <Query> <OrderBy> <FieldRef Name="ID"></FieldRef></OrderBy> </Query> <ParameterBindings> <ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" /> <ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_DEFAULT)" /> </ParameterBindings> </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>
View Code
开发已经完成了了,现在用Visual Studio将项目部署,进入网站已经能看到我的客户列表。
再选择Visual Studio发布,生成了一个.wsp的文件-SharePointProject1.wsp(SharePointProject1是项目名),这个文件就可以拿到生产环境部署了。
最后出于好奇,我把wsp文件解压缩,看看里面是什么(如果您的机器上的压缩软件不能直接解压,可尝试修改后缀名为cab。)。我看到的首先是一个清单文件(manifest.xml),一个DLL文件(SharePointProject1.dll),还有一个功能文件夹。打开清单文件看到里面有项目属性的信息,DLL文件和功能文件夹位置等;反编译DLL文件,看到的主要是程序集信息,因为这个项目没写什么C#代码,这里内容非常少。接着再打开功能文件夹,看到的是功能清单文件(Feature.xml),列表模版文件夹(MyCustomerList)、列表实例文件夹(MyCustomerList)。功能清单文件里有功能的属性信息、列表模版和列表实例的元素位置。列表模版和列表实例文件夹里都装着各自的元素文件(Elements.xml),其中列表模板文件夹里还有个Schema.xml文件,我们开发的东西都找到了!
参考资料:
1、《在 SharePoint 2010 中创建自定义列表定义》
http://msdn.microsoft.com/zh-cn/library/ff728096(v=office.14).aspx
2、《创建 SharePoint 的网站栏、内容类型和列表》
http://msdn.microsoft.com/zh-cn/library/vstudio/ee231593(v=vs.110).aspx
3、《创建自定义字段类型》
http://msdn.microsoft.com/zh-cn/library/bb862248(office.14).aspx
微软Web平台安装器下载:
http://www.microsoft.com/web/downloads/platform.aspx
相关文章推荐
- fcntl函数说明
- javascript弹出框打印某个数值时,弹出NaN?(not a number)
- 微信公众开放平台开发05---jetty部署异常:rg.apache.jasper.JasperException: PWC6345: There is an error in invoking ja
- java内存管理之二
- java内存管理之一
- 第四周作业---图的表示
- hdu 1164
- 生活,是如此的有意思。
- 就要毕业了,舍不得你们舍不得曾经的209
- 窗口对象的方法 prompt() 用来输入数据
- 插入排序算法
- Parencodings
- 扫雷背景
- 2014.4.3 今天主要是ListView和adapter
- javascript之文档碎片,文档碎片在理论上可以提高DOM操作的执行效率
- 【数据库】 mysql 指令
- jvm内存管理
- Nyoj 21 三个水杯
- 第4章: jQuery中的事件和动画---目录
- 财经法规二-2