By default, you’ll see 3 views in a SharePoint list. Using simple javascript, we can make sure our users see that fourth or fifth view as well, reducing the number of clicks it takes for them to get to the data they need.
Save the Scripts to your Site Assets
You’ll need a separate script in your site assets file for each number of views. I would recommend having multiple scripts in your Site Assets ready to be used at any time. That way if you add a view later, you just have to change the last number in your CEWP’s script field to update it. Just download the files you want and save them to your site’s Site Assets folder.
- Download All View Scripts in a Zipped Folder (view counts 4-8)
OR download individually… - 4 Views (view-count-4.js)
- 5 Views (view-count-5.js)
- 6 Views (view-count-6.js)
- 7 Views (view-count-7.js)
- 8 Views (view-count-8.js)
Alternatively, you can follow the directions below to create your own javascript files using SharePoint Designer. Just change the “5” in the script to the number of views you want to show and make sure your filename number matches. Skip to the next section if you just downloaded and saved the scripts.
- From within SharePoint Designer, click Site Assets
- Click the Asset dropdown, then JavaScript
- Name the file view-count-5.js, hit enter to save the name change
- Right-click the new file, and then click Edit File in Advanced Mode
- Paste the following script and save the file
[code]
<script type="text/javascript">
ExecuteOrDelayUntilScriptLoaded(overrideSurfacePivotCount, ‘clienttemplates.js’);function overrideSurfacePivotCount() {
ClientPivotControl.prototype.SurfacedPivotCount = 5;
};
</script>
[/code]
Add the Script to a List
- Go to your list for which you’d like to show more views
- Settings –> Edit page
- Add web part
- Add Content Editor Web Part (Media and Content–> Content Editor –> Add)
- Edit the new web part’s properties
- Get the URL for your script (i.e. /SiteCollection/SiteAssets/view-count-5.js). Here’s how to do that in SharePoint Designer:
- Right-click script –> Properties
- Copy URL
- Right-click script –> Properties
- Paste into CEWP and click OK
- Stop Editing/Save Page
- That’s it! You should now see the number of views that match the script you pasted.
Hi,
Thanks it works, but it also displays the “Modify this view” and “Create View”. I would like to have those two to only show when i click on the ellipses, or they only display to me simply because I’m an administrator on of the site?
works just for default view – ‘all items’, if you click on some view within a list, the list of views would be trimmed to the default 3…
You’ll need to add the reference to the script again after clicking each view. Each view is like its own page.