Explore the Experience in SharePoint 2013

Friday, March 13, 2015

What is List Defination in SharePoint and how to Create List Defination using Visual Studio ?

No comments

Hi Friends,

Thanks for visiting my blog...

   Today , I would like  to Post an about List Defination in SharePoint 2013

1. What is List Defination ?
2. Why  we need to list Defination ?
3. How to Create List Definition using  Visual Studio


 List Definition 

A list definition includes a Feature.xml file, an element manifest file (see List Template Files), and a Schema.xml file within a Feature folder (%ProgramFiles%\Common Files\Microsoft Shared\web server extensions\15\TEMPLATE\FEATURES).
 
A list template Feature includes a Schema.xml file that serves as the base file for a list definition. The List element is the root element of a Schema.xml file, which contains default view definitions, definitions for special fields used in the list, the toolbar definition for list views, content type declarations, and other metadata for the list.


Why we need List Definitions?
We need to have List Definitions for creating multiple list instances from it. This is the best way if we are dealing with data capture of same column types.
The built-in list definitions of SharePoint serve the same purpose. Example: Contact List, Task List, etc. Similarly depending on your project domain, it might be a good idea to turn common list formats into list definitions so that you can create multiple instances easily.
For example: a Computer Configuration list definition could be created for later creation of actual lists like Desktops and Laptops.

 How to Create List Definition using Visual Studio  
 
In Visual Studio 2012 select File | New Project
Select Templates | Visual C# | Office/SharePoint | SharePoint 2013 – Empty Project

If you don’t see this type of project available then you may need to download and install the Microsoft Office Developer Tools for Visual Studio 2012
Provide a name and location for the project/solution and OK
In the SharePoint Customization Wizard Prompt, configure the server to use for developing/debugging. If possible you will want to try and achieve a Sandboxed solution over a Farm Solution due to it’s ability to be able to be reused in more scenarios requiring less permission is the SharePoint environment.

Once the new solution has been created, we can use the new Visual Designer to create the List Definition. Right click the project in the solution explorer and select Add | New Item


Select Visual C# Items | Office/SharePoint | List, provide a name and click OK


Provide a display name for the list. We just want to create a list definition, not an instance of the list; This isn’t an option so what we do instead is go with the “Create a customizable list template and a list instance of it” and we will make some mods to the generated project files to remove the list instance so we are just left with the definition.



You should now see the list instance and definition files in solution explorer.

If you select the SettingsProfile in the solution explorer you will get the new List Visual Designer. Notice the “List” tab, this represents the instance of the list.


Since we only want the list definition, we are going to delete the list instance files from solution explorer. Select SettingProfileInstance, right-click and Delete.


You should now be left with just the list definition, the “List” tab will now be greyed out.

 Deploy the Solution in  your targeted web application .

 You Can able  to see the list names in quick launch

No comments :

Post a Comment