Since you are using SharePoint 2013 I would recommend you to consider the following approach. In SharePoint 2013 was introduced a so called Client Rendering Mode (CSR)
which is intended for rendering of List Views and Forms using HTML and JavaScript and which is a default rendering mode.
About View selector menu
As part of CSR ClientPivotControl
control (clienttemplates.js
) is intended for rendering View selector menu, SurfacedPivotCount
property defines the amount of view menu options rendered horizontally (default value is 3
)
How to display custom amount of view options for List View using CSR
The following template demonstrates how to override SurfacedPivotCount
property in order to display 4 view menu options:
function renderHeaderTemplateForDocuments(renderCtx, fRenderHeaderColumnNames){
var viewData = eval(renderCtx.ListSchema.ViewSelectorPivotMenuOptions);
ClientPivotControl.prototype.SurfacedPivotCount = 4;
return RenderHeaderTemplate(renderCtx, fRenderHeaderColumnNames); //render default Header template
}
SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
Templates: {
Header: renderHeaderTemplateForDocuments
}
});
How to apply the changes
There are at least two options how to apply the changes:
- Using JSLink property of XLV web part
- Place JavaScript template on page via
Script Editor
/Content Editor
web parts
Here is how to apply the changes using the second option:
- Switch the page (
NewForm.aspx
) into edit mode
- Add
Script Editor
webpart right below the list view web part.
- Put the specified code by wrapping it using
script
tag code into the Script Editor, for example: <script type="text/javascript">{Template JS code goes here}</script>
- Save the page
Result