Creare CustomList din Visual Studio


Elements.xml

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <!--Campul SPBuildInFieldId Title se trece ptr a fi facut ascuns in ShowInEditForm si ShowInNewForm la FieldRef-->
    <Field ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" 
           Name="Title" 
           SourceID="http://schemas.microsoft.com/sharepoint/v3" 
           StaticName="Title" 
           Group="_Hidden" 
           Type="Text" 
           DisplayName="Title" 
           Required="TRUE" 
           FromBaseType="TRUE" 
           Overwrite="FALSE" 
           xmlns="http://schemas.microsoft.com/sharepoint/" />
    <Field ID="{18D30CD6-C2F7-4e84-ADDF-7A4C3443CEB2}" 
           ListItemMenu="TRUE" 
           DisplayName="Customer ID" 
           Type="Number" 
           Required="TRUE" 
           StaticName="CustomerID" 
           Name="CustomerID" 
           Group="AdvWorks Group" />
    <Field ID="{DC29C843-8534-4f43-99E3-0BDD094E5572}" 
           DisplayName="Sufix" 
           Type="Choice" 
           Name="Sufix">
      <Default>Mr.</Default>
      <CHOICES>
        <CHOICE>Mr.</CHOICE>
        <CHOICE>Ms.</CHOICE>
        <CHOICE>Sr.</CHOICE>
        <CHOICE>Sra.</CHOICE>
      </CHOICES>
    </Field>
    <Field ID="{D94ADB92-599F-4cea-A627-FD4397E74A12}" 
           DisplayName="Prenumele" 
           Type="Text" 
           Required="TRUE" 
           StaticName="FirstName" 
           Name="FirstName" 
           Group="AdvWorks Group" />
    <Field ID="{B53D0413-C8BB-4541-A763-5A556FBEAF72}" 
           DisplayName="Numele" 
           Type="Text" 
           Required="TRUE" 
           StaticName="LastName" 
           Name="LastName" 
           Group="AdvWorks Group" />
    <Field ID="{7A1BAB99-8AAD-403f-886B-8A837F81B0A2}" 
           DisplayName="Compania" 
           Type="Text" 
           Required="TRUE" 
           StaticName="CompanyName" 
           Name="CompanyName" 
           Group="AdvWorks Group" />
    <Field ID="{C026590B-5D67-422b-9CF5-074EE930D2F2}" 
           DisplayName="Data nasterii" 
           Type="DateTime" 
           Format="DateOnly" 
           Required="TRUE" 
           StaticName="BirthDate" 
           Name="BirthDate" 
           Group="AdvWorks Group" />
    <Field ID="{A2590D0C-6A02-4241-9059-2DB08C7291E2}" 
           DisplayName="Telefon" 
           Type="Text" 
           Required="TRUE" 
           StaticName="Phone" 
           Name="Phone" 
           Group="AdvWorks Group" />
    <Field ID="{E88A894E-8F4A-4ed2-B6C3-744D7EB27322}" 
           DisplayName="Email" 
           Type="Text" 
           Required="TRUE" 
           StaticName="EmailAddress" 
           Name="EmailAddress" 
           Group="AdvWorks Group" />
    <ContentType ID="0x010089E3E6DB8C9B4B3FBB980447E313CE95" 
                 Name="CustomersContentType" 
                 Group="AdventureWorks Group" 
                 Description="ContentType de customeri" 
                 Inherits="FALSE"
                 Version="0">
      <FieldRefs>
        <!--se ascunde campul implicit Title-->
        <FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" 
                  Name="Title" 
                  Required="FALSE" 
                  ShowInDisplayForm="FALSE" 
                  ShowInNewForm="FALSE" 
                  ShowInEditForm="FALSE" />
        <FieldRef ID="{18D30CD6-C2F7-4e84-ADDF-7A4C3443CEB2}" />
        <FieldRef ID="{DC29C843-8534-4f43-99E3-0BDD094E5572}" />
        <FieldRef ID="{D94ADB92-599F-4cea-A627-FD4397E74A12}" />
        <FieldRef ID="{B53D0413-C8BB-4541-A763-5A556FBEAF72}" />
        <FieldRef ID="{7A1BAB99-8AAD-403f-886B-8A837F81B0A2}" />
        <FieldRef ID="{C026590B-5D67-422b-9CF5-074EE930D2F2}" />
        <FieldRef ID="{A2590D0C-6A02-4241-9059-2DB08C7291E2}" />
        <FieldRef ID="{E88A894E-8F4A-4ed2-B6C3-744D7EB27322}" />
      </FieldRefs>
    </ContentType>
  
    <!-- Do not change the value of the Name attribute below. If it does not match the folder 
name of the List Definition project item, an error will occur when the project is run. -->
    <ListTemplate
        Name="CustomersList"
        Type="10000"
        BaseType="0"
        OnQuickLaunch="TRUE"
        SecurityBits="11"
        Sequence="430" 
        DisallowContentTypes="FALSE"
        DisplayName="CustomerListDefinition"
        Description="Definitie lista customers"
        Image="/_layouts/images/itgen.png"/>
</Elements>

Schema.xml

<?xml version="1.0" encoding="utf-8"?>
<List xmlns:ows="Microsoft SharePoint" 
      Title="CustomerListDefinition" 
      FolderCreation="FALSE" 
      Direction="$Resources:Direction;" 
      Url="Lists/CustomerList" 
      BaseType="0" 
      xmlns="http://schemas.microsoft.com/sharepoint/">
  <MetaData>
    <ContentTypes>
      <ContentTypeRef ID="0x010089E3E6DB8C9B4B3FBB980447E313CE95"/>
    </ContentTypes>
    <Fields>
      <!--Campul SPBuildInFieldId Title se trece ptr a fi ascuns in ShowEdit si ShowNew-->
      <Field ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" 
             Name="Title" SourceID="http://schemas.microsoft.com/sharepoint/v3" 
             StaticName="Title" Group="_Hidden" Type="Text" DisplayName="Title" 
             Required="TRUE" FromBaseType="TRUE" xmlns="http://schemas.microsoft.com/sharepoint/" />
      <!--ListItemMenu="TRUE" face sa apara meniul itemului-->
      <Field ID="{18D30CD6-C2F7-4e84-ADDF-7A4C3443CEB2}" 
             ListItemMenu="TRUE" 
             ListItemMenuAllowed="Required" 
             DisplayName="Customer ID" 
             Type="Number" 
             Required="TRUE" 
             StaticName="CustomerID" 
             Name="CustomerID" 
             Group="AdvWorks Group" />
      <Field ID="{DC29C843-8534-4f43-99E3-0BDD094E5572}" 
             DisplayName="Sufix" Type="Choice" Name="Sufix">
        <Default>Mr.</Default>
        <CHOICES>
          <CHOICE>Mr.</CHOICE>
          <CHOICE>Ms.</CHOICE>
          <CHOICE>Sr.</CHOICE>
          <CHOICE>Sra.</CHOICE>
        </CHOICES>
      </Field>
      <Field ID="{D94ADB92-599F-4cea-A627-FD4397E74A12}" 
             DisplayName="Prenumele" Type="Text" 
             Required="TRUE" StaticName="FirstName" 
             Name="FirstName" Group="AdvWorks Group" />
      <Field ID="{B53D0413-C8BB-4541-A763-5A556FBEAF72}" 
             DisplayName="Numele" Type="Text" 
             Required="TRUE" StaticName="LastName" 
             Name="LastName" Group="AdvWorks Group" />
      <Field ID="{7A1BAB99-8AAD-403f-886B-8A837F81B0A2}" 
             DisplayName="Compania" Type="Text" 
             Required="TRUE" StaticName="CompanyName" 
             Name="CompanyName" Group="AdvWorks Group" />
      <Field ID="{C026590B-5D67-422b-9CF5-074EE930D2F2}" 
             DisplayName="Data nasterii" Type="DateTime" 
             Format="DateOnly" Required="TRUE" 
             StaticName="BirthDate" Name="BirthDate" 
             Group="AdvWorks Group" />
      <Field ID="{A2590D0C-6A02-4241-9059-2DB08C7291E2}" 
             DisplayName="Telefon" Type="Text" 
             Required="TRUE" StaticName="Phone" 
             Name="Phone" Group="AdvWorks Group" />
      <Field ID="{E88A894E-8F4A-4ed2-B6C3-744D7EB27322}" 
             DisplayName="Email" Type="Text" 
             Required="TRUE" StaticName="EmailAddress" 
             Name="EmailAddress" Group="AdvWorks Group" />
    </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="CustomerID"></FieldRef>
          <FieldRef Name="Sufix"></FieldRef>
          <FieldRef Name="FirstName"></FieldRef>
          <FieldRef Name="LastName"></FieldRef>
          <FieldRef Name="CompanyName"></FieldRef>
          <FieldRef Name="BirthDate"></FieldRef>
          <FieldRef Name="Phone"></FieldRef>
          <FieldRef Name="EmailAddress"></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="Customers" DefaultView="TRUE" 
            MobileView="FALSE" MobileDefaultView="FALSE" 
            SetupPath="pages\viewpage.aspx" 
            ImageUrl="/_layouts/images/generic.png" Url="AllItems.aspx">
        <Toolbar Type="Standard" />
        <XslLink Default="TRUE">main.xsl</XslLink>
        <RowLimit Paged="TRUE">30</RowLimit>
        <ViewFields>
          <!-- Campul Title este predefinit in SP si poate fi folosit-->
          <!--<FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" ShowField="FALSE" />-->
          <!--sau-->
          <!--<FieldRef Name="LinkTitle"></FieldRef>-->
          <FieldRef Name="CustomerID"></FieldRef>
          <FieldRef Name="Sufix"></FieldRef>
          <FieldRef Name="FirstName"></FieldRef>
          <FieldRef Name="LastName"></FieldRef>
          <FieldRef Name="CompanyName"></FieldRef>
          <FieldRef Name="BirthDate"></FieldRef>
          <FieldRef Name="Phone"></FieldRef>
          <FieldRef Name="EmailAddress"></FieldRef>
        </ViewFields>
        <Query>
          <OrderBy>
            <FieldRef Name="CustomerID"></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>

Si elements.xml de la ListInstance

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

Anunțuri

Lasă un răspuns

Completează mai jos detaliile tale sau dă clic pe un icon pentru a te autentifica:

Logo WordPress.com

Comentezi folosind contul tău WordPress.com. Dezautentificare / Schimbă )

Poză Twitter

Comentezi folosind contul tău Twitter. Dezautentificare / Schimbă )

Fotografie Facebook

Comentezi folosind contul tău Facebook. Dezautentificare / Schimbă )

Fotografie Google+

Comentezi folosind contul tău Google+. Dezautentificare / Schimbă )

Conectare la %s