We will see that how to create the custom list using List Definition without content type.
I am going to create a simple custom list “Status Master” with the following fields,
1. Status Name (Text)
2. Descriptions (Text)
3. Is Active (Boolean)
Step 1:
In Visual Studio 2010, open a new project and select the template (SharePoint => 2010 => List Definition)
Step 2:
Set the SharePoint site URL and select an option called “Deploy as a farm solution”.
Press “Next” for setting List Definitions.
Step 3:
Fill the display name of the list as “Status Master” and choose the list definition type as “Custom List” and click “Finish”.
Step 4:
In the solution explorer, rename the “List Definition1” to “Status Master” and rename the “ListInstance1” to “Status Master Instance”
Step 5:
Open the “Elements.xml” under the “Status Master” and do the following changes
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ListTemplate
Name="Status Master"
Type="10001"
BaseType="0"
OnQuickLaunch="TRUE"
SecurityBits="11"
Sequence="410"
DisplayName="Status Master"
Description="Which contains the Issue Statuses"
Image="/_layouts/images/itgen.png"/>
</Elements>
Note:
I have specified the Type value is 10001. For details, refer the following links
Step 6:
Open the “Elements.xml” under the “Status Master Instance” and do the following changes
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ListInstance Title="Status Master"
OnQuickLaunch="TRUE"
TemplateType="10001"
Url="Lists/Status Master"
Description="Status Master">
</ListInstance>
</Elements>
Step 7:
Open the “Schema.xml” file and do the following changes
Change the URL attribute in the List node as Url="Lists/Status Master"
Remove the <ContentTypes> tags under <MetaData>
Step 8:
In the “Schema.xml” file, add the following texts inside the <Fields> tag
<Field ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Type="Text" Name="Title" DisplayName="Status Name" Required="TRUE" />
<Field Id="{36E73DB3-9AE9-49B1-B01C-8AC0F77AF16C}" Name="Description" DisplayName="Description" Type="Text"></Field>
<Field Id="{B6D40FB5-CF22-4FC2-9C4E-14B3310B6818}" Name="IsActive" DisplayName="Is Active" Type="Boolean"></Field>
Note:
Instead of create the new column; I changed the “Title” column display name as “Status Name”
Step 9:
In the “Schema.xml” file, change the <ViewFields> under the <View BaseViewID="1" tag
<ViewFields>
<FieldRef Name="Attachments"></FieldRef>
<FieldRef Name="Title"></FieldRef>
<FieldRef Name="Description"></FieldRef>
<FieldRef Name="IsActive"></FieldRef>
</ViewFields>
Step 9:
Deploy the “SimpleList” project and check the SharePoint site.
Step 10:
Now we will see how to add default data for the “Status Master” list.
Open the “Elements.xml” under the “Status Master Instance” and add the following xml contents inside the <ListInstance tag
<Data>
<Rows>
<Row>
<Field Name="Title">New</Field>
<Field Name="Description">New</Field>
<Field Name="IsActive">True</Field>
</Row>
<Row>
<Field Name="Title">Fixed</Field>
<Field Name="IsActive">True</Field>
</Row>
<Row>
<Field Name="Title">Rejected</Field>
<Field Name="IsActive">True</Field>
</Row>
</Rows>
</Data>
Now try to redeploy the “SimpleList” project and check the SharePoint site.
You can find the sample here