Is there any way to display more than 3 views in OOTB SharePoint list or library.
4 Answers
SP 2013 uses clienttemplates.js to create the those views control. You can either create a JSLink or add the following script using the script Editor webpart to the page where your list view resides.
<script type="text/javascript">
ExecuteOrDelayUntilScriptLoaded(overrideSurfacePivotCount, 'clienttemplates.js');
function overrideSurfacePivotCount() {
ClientPivotControl.prototype.SurfacedPivotCount = 4;
};
</script>
You can find more details about the ClientPivotControl and other rendering techniques in the 'clienttemplates.debug.js'
-
1Excellent This Works. Thank you very much, i will look more into that js. Commented Sep 11, 2014 at 19:29
-
1The solution is perfect for when you want to update the number of views on specific list/library just remember you need to add the script editor to EVERY view for it to consistently show 4 views on each view. Commented Oct 11, 2018 at 10:14
1) You can edit the page that contains each view (Site Actions > Edit Page) and then insert a Content Editor Web Part. Within this web part, you can add links to each of your views and format/style them as needed.
2) The property that controls the default value is hidden by the XsltListViewWebPart control, so unfortunately we can't modify it to be a value of >3.
-
Hello Hardik, thanks for the response. I already tried the first option, is there any other work around or way to display 4 items instead . Commented Sep 11, 2014 at 13:33
-
currently no. but still i will try to get any and will update you. :) Commented Sep 11, 2014 at 13:38
Good hint about "ClientPivotControl" here, thanks!
However, inserting the above webpart script broke my CSS on list views for anonymous users so I found another workaround and thought I'd share it.
Basically, find all occurrences of variable "SurfacedPivotCount" in c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\LAYOUTS\ files and change it's values from default 2 or 3 to 6 (anything more than 3).
There will be 8 files to edit:
- clienttemplates.js
- clienttemplates.debug.js
- PivotControl.js
- PivotControl.debug.js
- search.analyticsrecommendation.js
- search.analyticsrecommendation.debug.js
- SP.UI.People.js
- SP.UI.People.debug.js
for example in SP.UI.People.debug.js in the line:
SP.UI.People.PeopleListViewPane.get_view().$Z_0.SurfacedPivotCount = 2;
change the value from 2 to 6.
-
This works an absolute treat if your looking to increase the default number of views right across the board for all lists and libraries. Commented Oct 11, 2018 at 10:10
There are 2 solutions for this. 1. Edit the page and add script editor and add below code:
<script type="text/javascript">
function renderHeaderTemplateForDocuments(renderCtx, fRenderHeaderColumnNames){
var viewData = eval(renderCtx.ListSchema.ViewSelectorPivotMenuOptions);
ClientPivotControl.prototype.SurfacedPivotCount = 5;
return RenderHeaderTemplate(renderCtx, fRenderHeaderColumnNames);
}
SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
Templates: {
Header: renderHeaderTemplateForDocuments
}
});
</script>
- Add the script to a JS file and refer it in your masterPage so as to apply this to all the Lists in your site.
function renderHeaderTemplateForDocuments(renderCtx, fRenderHeaderColumnNames) {
var viewData = eval(renderCtx.ListSchema.ViewSelectorPivotMenuOptions);
ClientPivotControl.prototype.SurfacedPivotCount = 5;
return RenderHeaderTemplate(renderCtx, fRenderHeaderColumnNames);
}
SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", overrideSurfacePivotCount);
Refer below article if you need to alter it to display the views conditionally: