Dieser Inhalt ist in Ihrer Sprache leider nicht verfügbar. Im Folgenden finden Sie die englische Version.

SP.ViewCollection Class

SharePoint 2010

Last modified: May 13, 2011

Applies to: SharePoint Foundation 2010

Represents a collection of SP.View Class objects.


The following example creates an Input button on an application page that adds a new view to the Tasks list of the current site, and displays the Tasks list’s current views.

<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<script type="text/ecmascript" language="ecmascript">

    var viewCollection = null;
    function runCode() {

        var clientContext = new SP.ClientContext.get_current();
        if (clientContext != undefined && clientContext != null) {
            var web = clientContext.get_web();

            var listCollection = web.get_lists();
            var list = listCollection.getByTitle("Tasks");
            this.viewCollection = list.get_views();

            var viewInfo = new SP.ViewCreationInformation();

            clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));

    function onQuerySucceeded() {
        var viewInfo = 'Tasks list current views: \n\n';
        var viewEnumerator = this.viewCollection.getEnumerator();
        while (viewEnumerator.moveNext()) {
            var view = viewEnumerator.get_current();
            viewInfo += view.get_title() + '\n';

    function onQueryFailed(sender, args) {
        alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());


    <input id="Button1" type="button" value="Run Code" onclick="runCode()" />