2

I've created multiple views for each individual working on a specific project. They will be using their unique view to view their assigned tasks. I wanted to hide the unique views from the dropdown when looking at the list. The views aren't confidential or anything, just having so many views in that dropdown can be a clutter.

I want to hide the new unique views JUST from the dropdown. I want each employee to still have access to other unique views from the list settings page or from the specific URL. This isn't a permissions issue, just a cosmetic request.

Example image

In the photo above, I want to hide the views in red.

1

You can rewrite the whole menu before rendering with CSR (Client Side Rendering)

Use the WYSiWYG Cisar Chrome Extension to replace the script:

SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function () {
  function init() {
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
      Templates: {
        Header: function (ctx, columns) {
          var views = JSON.parse(ctx.ListSchema.ViewSelectorPivotMenuOptions);
          //display all View options except 'Create View' & 'Modify View'
          ClientPivotControl.prototype.SurfacedPivotCount = views.length; 

         views = views.filter(function (view) {
            console.log(view.DisplayText, view);
            var isMenu=view.MenuOptionType===2;
            return isMenu || view.DisplayText.indexOf('View') <0; // false will not be returned
          });

          ctx.ListSchema.ViewSelectorPivotMenuOptions = JSON.stringify(views);//create string defintion again
          return RenderHeaderTemplate(ctx, columns); //render default Header template
        }
      }
    });
  }

  RegisterModuleInit(SPClientTemplates.Utility.ReplaceUrlTokens("~siteCollection/Style Library/hideview.js"), init);
  init();
});

This will delete(array.filter) all Views that not have the string 'View' in the DisplayText

Also note the option to list all Views (not just the 3 default)

You can also add View references, see the console fr the exact required syntax

iCSR iJS iView

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.