Follow us on Twitter
Follow us in Facebook
Office Dev Content
SharePoint Dev Content
In the Part I of this series, we were pleased to announce the SharePoint List Designer as one of the new features introduced in Visual Studio 11 Beta. Using the List Designer, you can quickly and visually build a SharePoint list within Visual Studio without having to create a list first in SharePoint Designer and then import it into Visual Studio.
To familiarize you with the List Designer, in Part I of this series, we provided a link to a MSDN Help topic that walks you through the process of creating a list and a content type by using the List Designer. If you’ve used the List Designer, you might want more details about its functionality. This blog post provides more information about it.
You may have already seen that when you add a new list item to a SharePoint project, a visual designer opens with three tabs: Columns, Views, and List.
Figure 1: SharePoint List Designer pages
Also, in Solution Explorer, a List node is created, consisting of two files (Schema.xml and Elements.xml) and a ListInstance node (under which there is an Elements.xml file).
Figure 2: SharePoint List item in the Solution Explorer
This all seems familiar to you if you’ve ever created lists using Visual Studio 2010. However with the designer support, you may wonder “What do each of these xml files represent?” or “How do these interact with the List Designer?”.
· How are designer pages associated with the XML files?
The Columns and Views pages in the designer enable you to customize columns and views in your list, respectively. All of the content in these pages comes from Schema.xml, which is located under the List node in Solution Explorer. A list schema can be reused to create different list instances.
The List page enables you to specify the list properties that are used in most cases. The properties values come from the Elements.xml file that resides in the List Instance node (located under the List node).
· When are the pages enabled and disabled in the designer?
You can open the SharePoint List Designer by either clicking the List node or the List Instance node. However, depending on the situation, different pages are enabled on the designer:
· If only one list instance references a particular list schema (defined in the Schema.xml file) in a SharePoint project, the List Designer launches with all three pages enabled whether you launch the designer by clicking the List node or the List Instance node.
· If there is more than one list instance reference in the same list schema in a SharePoint project, the List page is disabled when you launch the designer from the List node. If you move the mouse over the List tab, a tooltip appears and explains why it’s disabled.
Figure 3: Tooltip upon a disabled page
Similarly, when the designer is launched from a List Instance node, only the List page is enabled.
If the corresponding list schema or list instance doesn’t exist in the project, the Columns, Views or List pages are disabled accordingly.
You may have already enjoyed the efficiency of adding columns in the Columns page of the designer for Lists and Content Types, thanks to the filtering functionality in the drop-down list of the column’s Display Name.
Actually, through the filterable drop-down list in the designer for SharePoint List, there are two ways to add columns to a list: reuse site columns, or create new list columns.
· Reuse site columns
To quickly find a site column to reuse, type in any part of the site column’s display name. The drop-down list shows all of the columns containing that display name. The example below shows what appears in the drop-down list when you type “name”:
Figure 4: Filterable drop-down list
To reuse an existing site column, highlight it in the drop-down list and then press either the ENTER or Tab key. The column is then added to the list. Note that the type of a site column cannot be changed.
· Create new list columns
List columns are columns that exist only within the scope of the list. Creating a list column is fairly easy. On the Columns page, type the display name into the grid, making sure nothing is selected in the drop-down list, and then press Tab.
· Configure column properties
After adding a column to a list, you may want to configure the column’s properties. The Properties tab displays some of the most commonly-used column properties that you can configure. For additional column properties, click the column and then view the Properties window.
Some properties are valid only for a specific data type. You can view those properties by expanding the Type property in the Properties window.
Figure 5: Column properties in the Properties window
The columns that display in the New / Edit / Display forms of a list depend on the default content type (the first content type defined or referenced in the list schema) added to the list. To ensure that the columns you add to a list appear in these forms (which, in most of cases, you probably want), the designer generates a content type called ListFieldsContentType to reference all of the columns in the list, and then sets this content type as the default content type. This content type is defined inline in the list schema and is generated whenever you add or remove columns if the content type does not exist.
Figure 6: Generated content type in the Content Type Settings dialog
If you don’t need this content type, you can delete it from the Content Type Settings dialog box (which can be launched from the Columns page in the list designer) after you’ve completed adding and removing columns.
In this article, we looked in more detail into the SharePoint List Designer and what happens behind the scenes when working with the designer. We hope the SharePoint List Designer helps make your job easier and enables you to build lists more efficiently. If you have any comments or questions about the designer, please let us know. We look forward to hearing from you!
Microsoft Visual Studio SharePoint Developer Tools Team