View - Classe

Specifies a list view.

Hiérarchie d’héritage

System.Object
  Microsoft.SharePoint.Client.ClientObject
    Microsoft.SharePoint.Client.View

Espace de noms :  Microsoft.SharePoint.Client
Assemblys :   Microsoft.SharePoint.Client.Silverlight (dans Microsoft.SharePoint.Client.Silverlight.dll);  Microsoft.SharePoint.Client.Phone (dans Microsoft.SharePoint.Client.Phone.dll)  Microsoft.SharePoint.Client (dans Microsoft.SharePoint.Client.dll)

Syntaxe

'Déclaration
Public Class View _
    Inherits ClientObject
'Utilisation
Dim instance As View
public class View : ClientObject

Remarques

Use the DefaultView property of the List class to return the default view for a list, or the GetView() method to return a specified view. Use the GetViewFromUrl() method of the Web class to return a view for a list within a site, and use the View() property of the ViewFieldCollection class to get the parent view of the collection of view fields. Otherwise, use the Views property of the List class to return the collection of views for a list or the parent collection of views for a view.

Use an indexer to return a single view from a collection of views. For example, if the collection is assigned to a variable named collViews, use collViews[index] in C#, or collViews(index) in Visual Basic, where index is the index number of the view in the collection, the name of the view, or the GUID for the view.

Exemples

This code example orders the items on the Tasks list of the specified site in descending alphabetic order.

using System;
using Microsoft.SharePoint.Client;

namespace Microsoft.SDK.SharePointFoundation.Samples
{
    class ViewExample
    {
        static void Main()
        {
            string siteUrl = "http://MyServer/sites/MySiteCollection";

            ClientContext clientContext = new ClientContext(siteUrl);
            Web site = clientContext.Web;

            List targetList = site.Lists.GetByTitle("Tasks");
            ViewCollection collView = targetList.Views;
            View targetView = collView.GetByTitle("All Tasks");
            string strQuery = "<OrderBy><FieldRef Name=\'Title\' Ascending=\'False\' /></OrderBy>";
            targetView.ViewQuery = strQuery;
            targetView.Update();

            clientContext.ExecuteQuery();

            Console.WriteLine("Tasks list ordered in descending alphabetic order.");
        }
    }
}

Cohérence de thread

Tous les membres statique (Partagé dans Visual Basic)s publics de ce type sont thread-safe. Cela n’est pas garanti pour les membres d’instance.

Voir aussi

Référence

View - Membres

Microsoft.SharePoint.Client - Espace de noms