3.6. Adding List ViewsViews are web part pages used to view or edit lists. Most lists have the built-in views listed in Table 3-4. Table 3-4. Built-in list views
You can add new views to a list from the browser by displaying the list and following these steps:
There are three basic types of views:
Views can also be public or private. Public views can be seen by all members . Private views can only be seen by the member that created the view. Figure 3-11 shows the page for creating a new standard view. 3.6.1. Sorting, Filtering, and Highlighting with ViewsFigure 3-11 shows options for making the new view the default view for the list, making the view private, and which columns to include. You can also specify sorting, filtering, grouping, totals, and styles to customize the view. In other words, you can create views that highlight key items, such as the latest changes as shown by the New Today view in Figure 3-12. animal 3-11. Creating a new standard viewanimal 3-12. Using views to highlight items such as updates to the Shared Documents listI included New Today as a web part on my home page to draw my editor's attention to the files I've been working on. I created the view by adding a new standard view to the Shared Documents list with the following options selected (Figure 3-11):
There's no way to preview selected options, so you must create the view, then choose Modify settings and columns New Today if you want to change it. I tried a few different column and style settings before I settled on those shown above. 3.6.2. Displaying Views in Web PartsOnce I'm happy with the view, I add it to my home page as a web part. To do that:
animal 3-13. Changing the view for a list web partWeb parts that use views aren't updated if the view changes. Be sure you the view is final before you use it in a web part; otherwise you'll have to repeat the preceding procedure to see any changes. 3.6.3. Adding Views to List TemplatesWhen you create a custom list template based on an existing list, SharePoint includes all the views you've defined for the list. If you download the template from the list template gallery and extract manifest.xml from the downloaded file, you can see the list view definition in XML. The following snippet shows the definition for the New Today view: <?xml version="1.0" encoding="utf-8" ?> <ListTemplate WebUrl="http://wombat1/Using SharePoint 2003"> <Details> ... </Details> <Files> ... </Files> <UserLists> <List Name="{FCAA4E9E-BE51-49C9-8A34-C08691D2B0EB}" Title="Shared Documents" Description="Share a document with the team by adding it to this document library." Direction="0" BaseType="1" ServerTemplate="101" Url="Shared Documents" Version="0"> <MetaData> ... <View Name="{5B8C473E-B55F-4656-86E4-19F1C4C6F982}" Type="HTML" DisplayName="New Today" Url="Shared Documents/Forms/New Today.aspx" BaseViewID="1"> <ViewFields> <FieldRef Name="LinkFilenameNoMenu"/> <FieldRef Name="Title"/> </ViewFields> <Query> <Where> <Eq> <FieldRef Name="Last_x0020_Modified"/> <Value Type="DateTime"> <Today/> </Value> </Eq> </Where> </Query> <RowLimit Paged="TRUE">100</RowLimit> <ViewStyle ID="16"/> <GroupByHeader> <HTML> ... </HTML> </View> </Views> <Fields> <Field ColName="tp_ID" ReadOnly="TRUE" Type="Counter" Name="ID" DisplayName="ID" FromBaseType="TRUE"/> ... </Fields> <Forms> ... </Forms> <Security> ... </Security> <DocumentLibraryTemplate>Shared Documents/Forms/template.doc</DocumentLibraryTemplate> </MetaData> </List> </UserLists> <WebParts> ... </WebParts> </ListTemplate> The ViewFields element specifies the fields to include in the view. The Query element defines the filter applied to the view. You can get help on these and other elements in the SharePoint SDK. |