1

I have a list which is having more than 10 different views say All Tickets, My Tickets, Last Ticket, Project Tickets etc..

Every view has toolbar on the top for selecting different views, this toolbar shows views alphabetically with only first 3 views and ellipses ahead of that to select other views.

I want to change order of that views and also show 6-7 views on toolbar which more important for the users.

1

2 Answers 2

1

I'm still trying to find out how to specify an order for the list views, but here's how to specify the amount of views that shows up:

The first thing you need to do is crate a .htm file. I highly suggest using Notepad++, but you can also use plain ol' notepad. Enter the following code into the notepad document, and then save as an .htm file.

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

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

The "10" on the 4th line of code is where you enter how many views you want to have visible. Once you've saved the .htm file, upload it into your SharePoint site's site assets. Before you leave this page, go ahead and copy the URL for the .htm file.

enter image description here

Now, go to the SharePoint list in question. Edit the page (the page edit option is under the settings gear at the top of the page) and add a Content Editor Web Part (CEWP).

enter image description here

Edit the CEWP and paste the link for the .htm file in the link field and hit OK.

enter image description here

There should now be 10 views showing! Yay!

enter image description here

The trick is, you need to add the CEWP to every single view page (by clicking the settings gear while each view is selected). This is why I suggest using a CEWP with an .htm file. If you end up needing to change the amount of views, you only need to update the .htm file and upload it again (make sure you don't rename it and that you replace the file already uploaded).

I hope this helps!

2
  • Not necessarily needed to make this via pages. You can just add a script editor to each page, or the way I prefer save it in the masterpage gallery and add it via the JS-Link option under Advanced. Shown here: afrait.com/blog/display-more-than-3-views-en and here how to link it: afrait.com/blog/…
    – Patrick
    Commented Apr 27, 2016 at 8:42
  • Using this script makes the "Files" and "Library" tabs disappear.
    – Ofer Gal
    Commented Oct 11, 2017 at 13:24
0

I know this is an old post, but it comes up in the top search results so I thought I'd share a complete answer that has worked for me. Most of these solutions I see around the web seem to work, but they remove functionality. e.g. the 'Files' and 'Library/List' disappears after most of the HTM or JavaScript tricks. There are definitely ways to alleviate this with simple additions to those HTM/JS codes. The easiest solution I've found is to add a little extra code.

I'm sure someone can clean up the code below, but this is what I have found to work for me on SharePoint Online (and likely on-prem). Just copy and paste the entire thing onto the script editor (edit snippet) or HTM file, whichever you prefer.

The code below is just combined scripts from a couple sites. Sources/Credit listed at the bottom of this post.

<script type="text/javascript">
_spBodyOnLoadFunctionNames.push("focusOnListViewWebPart");
function focusOnListViewWebPart() {
  var elem = document.getElementById("MSOZoneCell_WebPartWPQ2");
  if(elem != null) {
    var dummyevent = new Array();
    dummyevent["target"] = elem;
    dummyevent["srcElement"] = elem;
    WpClick(dummyevent);
    _ribbonStartInit("Ribbon.Browse", true)
  }
}
</script>

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

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

Sources - Again, BIG Thanks to these sites for doing the leg work:

https://afrait.com/blog/display-more-than-3-views-en/

https://sharepointtechinfo.wordpress.com/2013/04/27/files-and-library-tabs-disappear-from-the-ribbon-menu-when-adding-a-web-part/

Hope this helps someone!

Your Answer

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

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