14 Sep 2011

List Definitions

A list definition is simply a formal representation, using an XML schema, of a list data model

 

Schema.xml - List Schema File

It describes all the metadata for the list data structure

<?xml version="1.0" encoding="utf-8"?>
<List xmlns:ows="Microsoft SharePoint"
Title="DevContacts"
FolderCreation="FALSE"
Direction="$Resources:Direction;"
Url="Lists/DevContacts"
BaseType="0"
EnableContentTypes="TRUE"
xmlns="http://schemas.microsoft.com/sharepoint/">
<MetaData>


<ContentTypes>
<!-- Here are referenced the content types -->
</ContentTypes>
<Fields>
<!-- Here are declared the list-level site columns -->
</Fields>
<Views>
<!-- Here are defined the views -->
</Views>
<Forms>
<!-- Here are declared the forms used to add, display, update items -->
</Forms>
<Validation>
<!-- Here are declared the validation rules for list items -->
</ Validation >
<Toolbar />
<!-- To define what kind of toolbar to use in the Web browser UI –>

</MetaData>
</List>

 

The BaseTypes values available are:
0 Generic/Custom List
1 Document Library
2 Not used, may be reserved for future use
3 Discussion Forum (deprecated, use 0 instead)
4 Vote or Survey
5 Issues List

Attributes for the List element:  http://msdn.microsoft.com/en-us/library/ms415091(office.14).aspx

 

View Element:

http://msdn.microsoft.com/en-us/library/ms438338(office.14).aspx

Example : View element of List xml

<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">

<Toolbar Type="Standard" />
<RowLimit Paged="TRUE">30</RowLimit>
<ViewFields>
       <FieldRef Name="Attachments">
      </FieldRef>
      <FieldRef Name="LinkTitle">
      </FieldRef>
</ViewFields>
<Query>
     <OrderBy>
         <FieldRef Name="ID">
         </FieldRef>
      </OrderBy>
</Query>
<XslLink>main.xsl</XslLink>
</View>

Query element is simply a CAML query. CAML stands for “Collaborative Application Markup Language

CAML Query : http://msdn.microsoft.com/en-us/library/ms467521(office.14).aspx

 

Forms element:

<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>

A Sample form created using List Definition with Form element

image

 

 

Custom View

<View BaseViewID="2" Type="HTML"
WebPartZoneID="Main"
DisplayName="All Customers"
DefaultView="FALSE" MobileView="TRUE"
MobileDefaultView="FALSE"
SetupPath="pages\viewpage.aspx"
ImageUrl="/_layouts/images/generic.png"
Url="AllCustomers.aspx">
<Toolbar Type="FreeForm" />
<XslLink>Contacts_Main.xsl</XslLink>
<RowLimit Paged="TRUE">20</RowLimit>
<ViewFields>
<FieldRef Name="Attachments">
</FieldRef>
<FieldRef Name="LinkTitle">
</FieldRef>
<FieldRef Name="DevContactID">
</FieldRef>
<FieldRef Name="DevCompanyName">
</FieldRef>
<FieldRef Name="DevCountry">
</FieldRef>
<FieldRef Name="DevCustomerLevel">
</FieldRef>
</ViewFields>
<Query>
<Where>
<Eq>
<FieldRef Name="ContentType" />
<Value Type="Text">DevCustomer</Value>
</Eq>
</Where>
<OrderBy>
<FieldRef Name="ID">
</FieldRef>
</OrderBy>
</Query>
</View>

 

XslLink : SharePoint will search for this XSLT file, Contacts_Main.xsl, in the SharePoint14_Root\TEMPLATE\LAYOUTS\XSL folder

<xsl:template match="View[@BaseViewID='2']" mode="full">
<!-- Here is our custom XSLT transformation -->
</xsl:template>

 

ListTemplate Definition File

The ListTemplate is the feature element file that declares all the deployment properties needed to provision the list definition

 

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ListTemplate
Name="DevContacts"
Type="10001"
BaseType="0"
OnQuickLaunch="TRUE"
SecurityBits="11"
Sequence="410"
DisplayName="Dev Contacts"
Description="A list of Contact for Dev"
Image="/_layouts/images/dlcon.png"/>
</Elements>

 

More detail on ListTemplate : http://msdn.microsoft.com/en-us/library/ms462947(office.14).aspx

No comments:

Post a Comment