List Definition
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 :
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 .
No comments:
Post a Comment