Create List Definition in SharePoint 2013

Leave a Comment
Hi All,

List Definition:

List definitions are the templates for creating the list.
List definition includes the schema for the list. I.e. what are fields in list, whether content type is associated or not, Views in list, form in list etc.
We created List Definition means does not the actual list exist but the template for creating the list is available.


following post is clearly , shown how to create list definition in share point.

http://camerondwyer.wordpress.com/2013/09/20/how-to-create-a-custom-sharepoint-list-definition-using-visual-studio-2012/

Post creating the solution , it contains the following things,

List Instance

  •  Elements.xml


     <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <ListInstance Title="NewListDef" OnQuickLaunch="TRUE" TemplateType="10001" Url="Lists/NewListDef" Description="My List Instance"></ListInstance>

</Elements>

List Definition:

  •   Elements.xml

          <ListTemplate
        Name="NewListDef"
        Type="10001"
        BaseType="0"
        OnQuickLaunch="TRUE"
        SecurityBits="11"
        Sequence="410"
        DisplayName="NewListDef"
        Description="My List Definition"
        Image="/_layouts/15/images/itgen.png"/>


  •   Schema.xml

       Contains Content Types,Views,Forms,Fields,...

<List xmlns:ows="Microsoft SharePoint" Title="Address" FolderCreation="FALSE" Direction="$Resources:Direction;" Url="Lists/Address" BaseType="0" xmlns="http://schemas.microsoft.com/sharepoint/" EnableContentTypes="TRUE">
  <MetaData>
    <ContentTypes>
    <ContentTypeRef ID="0x01">
        <Folder TargetName="Item" />
      </ContentTypeRef>
      <ContentType ID="0x0100fc947c3eafe0482782ad248238a10d82"      Name="ListFieldsContentType">
   <FieldRefs>
           <FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" />
        <FieldRef ID="{a85f8229-9e87-4ad5-8fc9-11435282efff}" Name="StreeNo" />
  </FieldRefs>
</ContentType>
<ContentTypeRef ID="0x0120" />
</ContentTypes>
    <Fields>      
    <Field ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Type="Text" Name="Title" DisplayName="ID" Required="TRUE" sourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Title" MaxLength="255" />
<Field Name="Name1" ID="{8ca8a154-d202-44c2-9b69-3717a6c79483}" DisplayName="Name" Type="Text" Required="TRUE" />
<Field Name="StreeNo" ID="{a85f8229-9e87-4ad5-8fc9-11435282efff}" DisplayName="StreeNo" Type="Text" />

</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="Name1" /><FieldRef Name="StreeNo" /><FieldRef Name="Dist" /></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>
<View BaseViewID="2" Name="b6016494-79dc-46b9-8bc3-acc7d6665849" DisplayName="UserView" Type="HTML" WebPartZoneID="Main" SetupPath="pages\viewpage.aspx" Url="UserView.aspx"><RowLimit>1</RowLimit><ViewFields><FieldRef Name="Name1" /></ViewFields><Query /><Toolbar Type="Standard" /><XslLink Default="TRUE">main.xsl</XslLink><JSLink>clienttemplates.js</JSLink></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>

Related Post

0 comments:

Post a Comment