Section 3.6. Adding List Views


3.6. Adding List Views

Views 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

View

Displays

AllItems.aspx

All items in the list. This is the default view for lists.

DispForm.aspx

A single item in the list (read-only).

EditForm.aspx

Data entry form for changing an existing item in the list.

NewForm.aspx

Data entry form for adding a new item to the list.


You can add new views to a list from the browser by displaying the list and following these steps:

  1. Choose Modify settings and columns Create a new view. SharePoint displays the Create View page.

  2. Name the view, select the fields to display and how to display them; then click OK to create the view.

There are three basic types of views:


Standard view

Displays the list in a very readable form.


Datasheet view

Displays list items in a spreadsheet-like grid that can be edited directly.


Calendar view

Displays items by month, week, or day. This is a handy view for time-critical lists such as appointments.

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 Views

Figure 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 view

animal 3-12. Using views to highlight items such as updates to the Shared Documents list

I 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):

Option

Setting

Name

New Today

Create a Public View

Selected

Columns (selected columns)

Name (linked to document)

 

Title

Sort

None

Filter

Show items only when the following is true:

 

Modified is equal to [ Today ]

Style

Newsletter, no lines


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 Parts

Once I'm happy with the view, I add it to my home page as a web part. To do that:

  1. On the home page, choose Modify Shared Page Add Web Parts Browse. SharePoint displays the Add Web Parts task pane.

  2. Click the title bar on the new web part and select Modify Shared Web Part. SharePoint changes the task pane to edit the web part, as shown in Figure 3-13.

  3. In the task pane, change the Selected View to New Today, change the title of the web part, and click OK. SharePoint makes the changes and closes the task panel.

animal 3-13. Changing the view for a list web part

Web 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 Templates

When 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.



Essential SharePoint
Essential SharePoint 2007: A Practical Guide for Users, Administrators and Developers
ISBN: 0596514077
EAN: 2147483647
Year: 2005
Pages: 153
Authors: Jeff Webb

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net