1

I have a question regarding SharePoint list views. When I visit a SharePoint List, I can see the rest of the SharePoint views as like the below screen capture.

enter image description here

I want to know, is there a way to change the order of this list of views in horizontally?

Please guide me to solve this.

Thanks and regards, Chiranthaka

2

I think they are in alphabetical order so if you name them '1. All Items' '2 In Progress', 3. Date difference' you should be able to control the sequence.

  • Except that, is there any other solution? – ChiranSJ Mar 29 at 10:23
0

By default, the views will be sorted alphabetically in the toolbar of the list view and in the ribbon.

To change the order of list views, you can use JS Link in web part properties. Please find the below steps:

1.Save the below script as ListOrder.js and upload it to Site Assets(or Master page Gallery)

2.Refer it in JS Link as ~site/SiteAssets/ListOrder.js for the specific view in a list.

3.specify your view names in the "viewNames" array.

(function () {     
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
      'Templates': {
        'Header': renderHeaderTemplateForDocuments
      }
    }); 

    // enter all views here in the desired display order
    var viewNames = ['Slides', 'All Pictures', 'Thumbnails', '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;
    }
})();

NOTE: Order will be applied only to the view to which JS Link is referred.

For more detailed information, refer to the following similar issue posts:

https://social.msdn.microsoft.com/Forums/office/en-US/46eae1f3-947e-468d-a842-41089444f9de/how-do-i-change-the-displayed-view-order-for-a-list-in-sharepoint-2013?forum=sharepointdevelopment

How do I change the displayed view order for a list in SharePoint 2013?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.