CSC510205. SPView scope is not defined.

Description

How'd we know what people want - folder, inside folder, or just items?
SPView has an "affected scope". It can be one of the follow:

Member name Description
Default Show only the files and subfolders of a specific folder.
Recursive Show all files of all folders.
RecursiveAll Show all files and all subfolders of all folders.
FilesOnly Show only the files of a specific folder.

All enumeration values are covered all possible developer's intentions. Other words, without specified, SharePoint will use Default value. It is not always correspond develepers needs now or later espetially in case of new folder added. Notify about missing Scope we give developer change to specify it's architecture approach.

using (SPSite site = new SPSite("http://intranet.contoso.com/sites/contracts"))
{
    using (SPWeb web = site.OpenWeb())
    {
        char[] ViewFieldSepartors = new char[] { ';' };
        string viewFields = "Title;Department";
        SPList list = web.Lists["DOC1"];
        StringCollection fields = new StringCollection();
        fields.AddRange(viewFields.Split(ViewFieldSepartors, System.StringSplitOptions.RemoveEmptyEntries));
        SPView view = list.Views.Add("TestView", fields, string.Empty, 100, true, false);
        view.Scope = SPViewScope.Recursive;
        view.Update();
        list.Update();
    }
}

Links

SPViewScope enumeration

Last edited Mar 12, 2014 at 12:39 PM by dvd73, version 1

Comments

No comments yet.