Saturday, January 18, 2014

Hide Sharepoint 2007 (and 2010) Action Menu items using JQuery

I recently had a need to remove the ability for people to access the "Edit in Datasheet" and "Alert Me" menu items in a specific list without changing the system overall. It seemed simple enough, but for various reasons, it was not. The most difficult part of it was finding the correct element, as SharePoint (and ASP.NET) prefixes all id's with a head value. 

Annoying Menus! Especially Edit in Datasheet!
In order to hide the items from the menu, I had to determine the ID's of those items. Luckily, a post by Mike Smith had the specific elements to hide - much easier than viewing source constantly: 

Once the elements were found, using jQuery selectors to find the suffixed elements sealed the deal. 


<script> 
$(document).ready(function(){     

  $("[id*='_SubscribeButton']").remove(); 
  $("[id*='_EditInGridButton']").remove();
  $("[id*='_ExportToDatabase']").remove();
  $("[id*='_ViewRSS']").remove();
}); 
</script>


The end result: One item to select and no web parts or features to install.


Reference:



No comments:

Post a Comment

Image noise comparison methods

 1. using reference image technique     - peak_signal_noise_ratio (PSNR)     - SSI 2. non-reference image technique     - BRISQUE python pac...