SharePoint 2013: Create Custom List Template and Set Default View To Datasheet View Programmatically

Posted: July 20, 2014 in SharePoint2013

Introduction

SharePoint provides many ways to show the content of a list. SharePoint Views are one of them to present the data in various manners with various columns, styles, sorting, filtering, and grouping. In SharePoint, views can be one of the two categories Public and Private.

Public Views are available to every user who is a site member on the site.

Private View is available for only the user that has created that specific view.

SharePoint by default provides various types of views, such as Calendar View, Datasheet View, and Gantt View and so on.

A Datasheet View displays the items in Microsoft Excel format that allows us to copy and paste data from and into the list.

Datasheet views in SharePoint 2010 are great for performing bulk updates on list items and document properties in a library. A Datasheet view is a great way to quickly change the content type of a list item or document

Let’s Process Following steps

Create a custom list definition (not a list instance) using the Visual Studio 2012 visual designer shown step-by-step with screenshots.

In Visual Studio 2012 select File | New Project

Select Templates | Visual C# | Office/SharePoint | SharePoint 2013 – Empty Project

SharePoint 2013

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.

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”

Create a customizable list templateList instance Select Schema.xml edits View Base view ID section Add Type =”Grid“ as in the following format for the Datasheet view.

<ViewBaseViewID=1Type=GridWebPartZoneID=MainDisplayName=$Resources:core,objectiv_schema_mwsidcamlidC24;DefaultView=TRUEMobileView=TRUEMobileDefaultView=TRUESetupPath=pages\viewpage.aspxImageUrl=/_layouts/15/images/generic.png?rev=23Url=AllItems.aspx>

  <ToolbarType=Standard />

  <XslLinkDefault=TRUE>main.xsl</XslLink>

  <JSLink>clienttemplates.js</JSLink>

  <RowLimitPaged=TRUE>30</RowLimit>

  – <ViewFields>

    <FieldRefName=LinkTitle />

  </ViewFields>

  – <Query>

    – <OrderBy>

      <FieldRefName=ID />

    </OrderBy>

  </Query>

  – <ParameterBindings>

    <ParameterBindingName=NoAnnouncementsLocation=Resource(wss,noXinviewofY_LIST) />

    <ParameterBindingName=NoAnnouncementsHowToLocation=Resource(wss,noXinviewofY_DEFAULT) />

  </ParameterBindings>

</View>

</Views>

 xml Code
Save and deploy the solution in an extented webapplication, then:

Go to Site Content Create New list user our own create Templete for Custom List in Datasheet view (CustomDataSheetListTemplate).

Custom List in Datasheet view

Custom List in Datasheet view
Custom List
ListSummary

In this article we explored a practical scenario of creation with List Instance Datasheet view. The source code is associated with this article.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s