SharePoint Customization Tricks: Part I
This multipart series of articles is intended to help you get ramped up with SharePoint customizations. In this article we will see how to hide List View Toolbar Menu Items.
This multipart series of articles is intended to help you getting ramped up with SharePoint Customization. It's about modifying the default SharePoint user experience, list forms customization, branding, skinning SharePoint portals, etc. When I looked around the "SharePoint Landscape", I noticed the lack of documented experiences in the SharePoint customization area and thus this multipart series of articles was born.
Trick #1 : Hiding List View Toolbar Menu Items!
I've gone through SharePoint projects on different scales; a common requirement among most of these projects is hiding some menu items that are implemented by default within the framework of SharePoint. The obvious choice from the SDK is HideCustomAction ! After digging through the web, I found out the following:
The "HideCustomAction" feature can merely hide the items which have been rendered through the "CustomAction" feature framework such as Site Actions and Site setting.... etc.
The ListViewWebPart menu items ( New menu, Upload menu, Actions menu,... etc ) are rendered through a class library as a web control from the Microsoft.SharePoint.dll so they can't be hidden through The "HideCustomAction" feature.
hideListViewToolbarItems("Edit in Datasheet","export to Spreadsheet","view rss feed","settings:create view");
var menuItemNames=new Array("edit in datasheet","open with windows explorer",
"connect to outlook",'export to spreadsheet','view rss feed','alert me'
,"create column","settings:create view","list settings",
"document library settings","explorer view","all documents",
"all items","modify this view","view:create view","new document",
"new item","new folder","upload document","upload multiple documents");
var menuItems = new Array("EditInGridButton","OpenInExplorer","OfflineButton",
var allMenuItems = document.getElementsByTagName('ie:menuitem');
for(var i = 0; i < hideListViewToolbarItems.arguments.length; i++ )
menuItemIndex = j;
for (var l = 0; l < allMenuItems.length; l++)
menuItemName = menuItemName.split(":");
&& allMenuItems[l].text.toLowerCase() == menuItemName )
// For FireFox Compatibility
var parentNodeOfMenuItem = allMenuItems[l].parentNode;
You can use this function to hide any menu items rendered in the ListViewWebPart toolbar which is used in the list view pages, just call the function and pass the menu item names ( comma separated ) as they appear in the toolbar ignoring the case. Only one exception to that when you need to hide "Create View" which appears twice one in "List Settings" and the other one in the view selector, in order to resolve this conflict just call the function as follows :