1

I have an odd problem with a SharePoint 2010 document library that uses document sets. I wanted to flatten the document sets in a grouped view to show the contents of all document sets together. I found that when I set the Folders group in the view to "Show all items without folders", the view does not display a link for the document sets. Instead it just shows the name of the document set as static text with the usual rollover context menu. The documents contained within the document sets do have links. This is strange, and the consequence is that this view cannot be used to access the document sets' welcome pages. Has anyone else encountered this and is there a workaround? Thanks.

Matt

1 Answer 1

1

You can take a look at the View Element Schema https://msdn.microsoft.com/en-us/library/office/ms438338.aspx?f=255&MSPPError=-2147217396.

Where you would need to change the list view "Scope" property to "Recursive" in order to get the desired result.

SCOPE - Optional Text. Specifies the recursive scope for a view of a document library. Possible values include the following: FilesOnly—Show only the files of a specific folder. Recursive—Show all files of all folders. RecursiveAll—Show all files and all subfolders of all folders. If this attribute is not set, the view displays only the files and subfolders of a specific folder. The value of this attribute corresponds to the Scope property of the SPView class.

In C# CSOM code your method should look something like this:

    private void CreateView(string[] fields)
    {
        var lists = _web.Lists;
        var existingLists = _context.LoadQuery(lists.Where(x => x.Title == _listName));
        _context.ExecuteQuery();
        var list = existingLists.FirstOrDefault();

        var viewColl = list.Views;
        _context.Load(list.Views);
        _context.ExecuteQuery();

        // Specifies the properties used to create a new list view 
        var creationInfo = new ViewCreationInformation();  
        creationInfo.Title = "Flat View";  
        creationInfo.RowLimit = 100;
        creationInfo.ViewFields = fields;  
        creationInfo.ViewTypeKind = ViewType.None;  
        creationInfo.SetAsDefaultView = true;
        viewColl.Add(creationInfo);  
        _context.ExecuteQuery();  

        _context.Load(list.Views);
        _context.ExecuteQuery();

        var flatView = list.Views.GetByTitle("Flat View");
        flatView.Scope = ViewScope.Recursive;
        list.Update();
        flatView.Update();
        _context.ExecuteQuery();
    }

The code introduses new view in a list (not optimized for your case) and not optimized as code, but you can get the idea.

the important line is to set the scope

flatView.Scope = ViewScope.Recursive;

and then update the view.

1
  • I've decided to accept his answer even though this is not something I've being trying to do for years. It looks sound.
    – flayman
    Sep 27, 2019 at 11:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.