Tuesday, July 19, 2016

Hide a SharePoint ECB menu

 There was a requirement to hide a  menu item in  a  document library. The specific menu item is "Compliance Details".

After poking around JavaScript for sometime and the CSS fix looks elegant because of the CSS selectors.

Add a script editor web part and add the below

li.ms-core-menu-item[text="Compliance Details"]
 {display: none !important;}

This is actually find all "li" with class "ms-core-menu-item" where the attribute "text" value is "Compliance details" then assign the new style.

CSS selectors allow us to match any menu item by matching them with a display text of the menu.

No comments: