现在的位置: 首页 > 综合 > 正文

自定义字段的妙用

2013年11月19日 ⁄ 综合 ⁄ 共 2284字 ⁄ 字号 评论关闭

信息来源:

Joris [MVP Windows SharePoint Services]
就是那个在自己blog上放了超级多资源链接的那个大牛……
 
据称,SharePoint SDK上介绍如何订制列表模板的文章缺少了一步(我自己还没机会试,估计咱们这儿需要这么深度改列表模板的兄弟也不多,留这篇文章做参考吧)
 
但缺少的那步可以这样弥补。转引如下:
(注,他应该会在最近写一篇博详细说这个问题,大家可以关注一下)
 

The SharePoint SDK shows How to - Create a Custom List Definition but is strange enough not complete. If you follow the SDK sample - the extra field you created in your custom list definition will NOT show up in the SharePoint form pages (Edit item, new item and view item).

In the next posting, I will describe in short the different steps - the last step is the one which I think is missing.

· Create a new feature as explained in the SharePoint SDK. Afterwards install and activate the feature.

· Modify the SCHEMA.XML file - Add your custom field inthe Fields section

<Fields>
<Field Type="Choice" Name="FavoriteColor" DisplayName= "Favorite Color"

ID="{5F11FE7B-C8D4-4849-A400-133352D17ECF}">

 <CHOICES>

  <CHOICE>Red</CHOICE>

  <CHOICE>Green</CHOICE>

  <CHOICE>Blue</CHOICE>

 </CHOICES>

</Field>

</Fields>

· Add a reference to the Field you defined within the ViewFields section

<ViewFields>
 <FieldRef Name="Attachments" ></FieldRef >
 <FieldRef Name="LinkTitle" ></FieldRef>
 < FieldRef Name="FavoriteColor"></ FieldRef>
</ViewFields>

· Modify the ContentTypes section and modify the Item contenttype to include the custom column. This change will make sure that the custom column will also show up in the edit and new forms.

<ContentTypes>

 <ContentTypeRef ID="0x0120" />

 <ContentType ID="0x0100EE310F92BD4F4ee79829A2FB3A01F1ED"

 Name="Item" Group="List Content Types" Description

 ="Create a new list item." Version="2" FeatureId=

 "{695b6570-a48b-4a8e-8ea5-26ea7fc1d162}">

  <FieldRefs>

   <FieldRef ID="{c042a256-787d-4a6f-8a8a-cf6ab767f12d}"

   Name="ContentType" />

   <FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}"

   Name="Title" Required="TRUE" ShowInNewForm=

   "TRUE" ShowInEditForm="TRUE" />

   <FieldRef ID="{5F11FE7B-C8D4-4849-A400-133352D17ECF}"

   Name="FavoriteColor"/>

  </FieldRefs>

  <XmlDocuments>

  <XmlDocument NamespaceURI="

       http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">

   <FormTemplates xmlns="

          http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">

    <Display>ListForm</Display>

    <Edit>ListForm</Edit>

    <New>ListForm</New>

   </FormTemplates>

  </XmlDocument>

 </XmlDocuments>

 <Folder TargetName="Item" />

</ContentType>

</ContentTypes>

· Finally create a new list using the new custom SharePoint list definition

  

抱歉!评论已关闭.