Sharepoint - How do I change the displayed view order for a list in SharePoint 2013?
Below is the javascript for JSLink(display template) file which does the custom sorting. You need to modify the 'viewNames' array to include the view names for your list. Add them to the array variable in the order you wish to see them on your page. You need to edit the webpart properties and add a link to this JSLink file for each view page if you want the order to show up in all the views.
(function () {
SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
'Templates': {
'Header': renderHeaderTemplateForDocuments
}
});
// enter all views here in the desired display order
var viewNames = ['All items', 'Test', 'Dept View', 'HomePage', 'Modify this View', 'Create View'];
function renderHeaderTemplateForDocuments(renderCtx, fRenderHeaderColumnNames){
var viewData = eval(renderCtx.ListSchema.ViewSelectorPivotMenuOptions);
// update with an integer to specify the number of displayed views
ClientPivotControl.prototype.SurfacedPivotCount = viewData.length; //display ALL available menu options
viewData.sort(compareMenuOptions); //sort menu options in order specified in the array
renderCtx.ListSchema.ViewSelectorPivotMenuOptions = JSON.stringify(viewData);
return RenderHeaderTemplate(renderCtx, fRenderHeaderColumnNames); //render Header template
}
function compareMenuOptions(a,b) {
if(a.DisplayText != undefined && b.DisplayText != undefined){
var x = viewNames.indexOf(a.DisplayText);
var y = viewNames.indexOf(b.DisplayText)
if (x > y)
return 1;
if (x < y)
return -1;
}
return 0;
}
})();
That order is alphabetical. I would put numerical prefixes. 01. Comments 02. Category grouped 03. Active Projects
Alternatively, I would abandon the views on the top nav and add a section in the left quick launch for important views, assuming this is the main list/library on the site. You can order that however you like. Last ditch would be a link list of views. You could add a sort order column and make links to your views.