Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

Hide the delete menu item from a specific document library

$
0
0

I want to hide the Delete  item menu option for a specific document library.Since it is for a specific library I would not lie to use customcore.js approach.Please sugest some useful javascript for same.

I have already used below javascript in CEWP which I added on the document library page itself(allitems.aspx) but yeild no results:

<script type="text/javascript">
 
var elemTable=document.getElementById('ECBItems');
 
if (elemTable !=null) {
     var elemTBody=elemTable.childNodes[0];

//iterate each table row to find the correct ECB menu item to hide(remove)

   for (var iMenuItem=0; iMenuItem < elemTBody.childNodes.length; iMenuItem++) {
         var elemTR=elemTBody.childNodes[iMenuItem];
         var elemTDTitle=elemTR.childNodes[0];
         var title=GetInnerText(elemTDTitle);
 
 //here we filter on title, but the table contains more information if need be
 
        if(title =='Delete') {
             elemTBody.removeChild(elemTR);
         }
     }
 }
 
</script>

Please suggest which can be kept specific and requires no change in masterpage as same masterpage is used across the site.


Viewing all articles
Browse latest Browse all 11571

Trending Articles