Friday, July 31, 2015

Display more than three views in SharePoint 2013 library or list

A few weeks back, a coworker asked me to expand the number of views shown in a SharePoint list. SharePoint shows only the first three view links by default, but includes ellipses (three dots) to expand the selection of views available (as shown below).




I had heard that it wasn't possible to change this setting, so I informed my co-worker, unfortunately, we can't do anything about it.

But as usual, I hate giving the "It's not possible" answer, so I started to dig into the issue and see if someone had a solution. Lo and behold, someone had! Thanks to Aveenav who posted the answer on SharePoint StackExchange.

If you're familiar with SharePoint 2013, implementing the solution is relatively straightforward. However, I've included instructions below to help the rest of us out.

1.  Go to the list or library where you want to see additional views.
2.  In the upper right corner of the page, click the cog and select Edit Page.


3.  Click Add a Web Part in the main window area.

4.  In the webpart Categories, scroll down and select Media and Content. Select Script Editor and click Add.

5. In the Script Editor, click Edit Snippet.

6. In the Embed window, paste this code.

<script type="text/javascript">
ExecuteOrDelayUntilScriptLoaded(overrideSurfacePivotCount, 'clienttemplates.js');

function overrideSurfacePivotCount() {
   ClientPivotControl.prototype.SurfacedPivotCount = 4;
};
</script>

7.  The "4" in the script above determines how many view selections to show. Change this number as needed. Click Insert on the Embed window.

8.  Click Stop Editing in the upper left of the SharePoint ribbon.

9.  Test the views.

I've increased the number of view selections available to 15 and encountered no issues. If the views are extended to the point of going beyond the width of the page, the view selections will wrap to the next line.

Hopefully, this procedure will be handy for you if you get a similar request.



5 comments:

  1. Hi Christel, thanks for sharing, very helpful. I have noticed that you have to repeat this procedure for each different view of the same library (or list). Is it correct?

    ReplyDelete
  2. Yes. Have to repeat this procedure for each different view of the library or list.

    ReplyDelete
  3. Can we do this on a custom site page? I have inserted my list on my home page but would like to show all my views as links, is this possible?

    ReplyDelete
  4. Will this work for SharePoint Online?

    ReplyDelete
  5. This fixed my problem, thank you very much for sharing!

    ReplyDelete