17

Is there any way to display more than 3 views in OOTB SharePoint list or library.

enter image description here

4 Answers 4

23

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>

enter image description here

You can find more details about the ClientPivotControl and other rendering techniques in the 'clienttemplates.debug.js'

2
  • 1
    Excellent This Works. Thank you very much, i will look more into that js. Commented Sep 11, 2014 at 19:29
  • 1
    The 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.
    – cod3r_jim
    Commented Oct 11, 2018 at 10:14
3

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.

2
  • 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
2

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:

  1. clienttemplates.js
  2. clienttemplates.debug.js
  3. PivotControl.js
  4. PivotControl.debug.js
  5. search.analyticsrecommendation.js
  6. search.analyticsrecommendation.debug.js
  7. SP.UI.People.js
  8. 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.

1
  • This works an absolute treat if your looking to increase the default number of views right across the board for all lists and libraries.
    – cod3r_jim
    Commented Oct 11, 2018 at 10:10
0

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>
  1. 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:

How to display more than 3 views in SharePoint List

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.