Access site and list data for the SharePoint server-side object Model (Part 3)

Source: Internet
Author: User

(iii) View

Similar to a data view in the traditional sense, a list view in SharePoint specifies the filter criteria for the data in the list, sort criteria, grouping criteria, display columns/fields, number of items displayed, display style, and so on. In SharePoint, use SPView to represent a list view and use Spviewcollection to represent a collection of views.

In SharePoint, as the primary display for lists, document libraries, each view should have a URL (that is, the address of the page on which the view resides). In fact, when we insert a Web Part into a page to select the "List and library" category, or directly choose to insert an "existing list" (as shown in), a new view of that list or document library is actually created, and the address of that view is the page where the Web Part resides.

1. Access to Views

There are several ways to get views:

(1) Use SPList's DefaultView property to get the default view of the list;

(2) Use the SPList View property (spviewcollection type) to get all the views in the list, and then use the indexer to get a specific view:

    • Views[idx]:int type indexer, obtained by subscript, seldom used;
    • Views[id]:guid-type indexer, based on the GUID of the view;
    • The views[name]:string-type indexer, which is obtained according to the name of the view, is more commonly used.

Use the SPWeb Getviewfromurl method to get the view using the URL of the relative web site of the view.

2. Common Properties of views

Some common properties of SPView are as follows:

Name

Type

Description

Query

String

View filtering, sorting, grouping criteria, CAML format

RowLimit

UInt

The number of entries displayed by the view (or the number of entries per page)

Title

String

The name of the view

Url

String

The URL for the view relative to the Web site

Serverrelativeurl

String

The URL for the view relative to the server

ViewFields

Spviewfieldcollection

Collection of fields displayed by the view

In the query property of the view, we first saw the XML format of CAML, in which the filter criteria, sorting criteria, and grouping criteria for a list are defined in the form of CAML. Readers can use Visual Studio's Server Explorer to see the query properties for different lists, in different sorting filters, and to have a preliminary impression of CAML for queries. The specifics of CAML and list queries are described later in this chapter in a specific section. It is worth noting that, in the View Settings page, we can only set 2 sorting criteria, but by using code to modify the query property, we may set a number of sorting criteria, but the grouping condition can still only set two.

Access site and list data for the SharePoint server-side object Model (Part 3)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.