Saturday, January 20, 2007

Hiding SharePoint 2007 List Context Menu Items


Am sure lot's of people would be wondering how to hide menu items of a list eg document libraries "Send to " menu item .



In olden days of SharePoint 2003 this used to be achieved using playing around with the OWS.jss file ,though the customization is same in SharePoint 2007 too but the file has been changed . Now the modifications needs to be done in CORE.JS file located at "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033\CORE.JS"


Let's change the file and see the difference , In order to hide menu item e.g "Send to " search for function named "AddSendSubMenu()" in CORE.JS and comment the function call . as shown in figure below:




That's it check the menu in doc lib now , does it looks like mine:-)




NOTE: Make sure you take back up of Core.js file before making any change in order to prevent any server functionality malfunction.

10 comments:

N@poleone said...

Hi,
I'm trying to disable some of the context menu using a webpart to override the appropriate function, but I cannot manage to disable the menu item only for a content type of a doclib and not for all.

Can you help me?

ruippinto10@gmail.com said...

Hi,
What i would like to do is, how can i hide some of that buttons,from the dropdown, associated with permission level or permission group.
For example, i've got a permission level with the options edit,add documents, that i'm using in documents library, but i'de like that he couldn't publish documents. How can i hide the publish major version button in order to the logged user, with different permission level?

Thanks

Prash said...

I want to use this as feature , so i can activate or unactivate...

- Can anyone let me know how to approach??

Thanks in advance :)
PrashanthSpark

Anonymous said...

I am also looking for an approach to hide context menu items using a feature. Please let me know if anybody knows it. Thanks.

Andrew said...

I used an AJAX type interface to do this. You will have to do this you want to hide options based on other criteria not normally available to the javascript that renders the menu.

You will have to rebuild the menu from scratch, while applying your specific rules to skip specific items.

http://www.buildcoolshit.com/SP/Lists/Posts/Post.aspx?ID=5

Anonymous said...

I've tried the solution that is showed and it didn´t work....

Anonymous said...

...try iisreset...

sanketinfo said...

Hey,

Very nice article and good information!!

I have different situation from this and I am looking for solution, can you please help me for this?

I would like to remove menu items “Edit Item” from specific custom list, if I go with above solution then it will remove menu options from all custom list, but what I need to do for removing option from only one list.

OR

Is there any way in which I can change URL of "Edit Item" page from EditItem.aspx to my layouts custom ASPX page? In SP designer, while changing page name (supporting files) from custom list, I can't see files from layouts folder ..

Actually finally I am looking for to give my custom ASPX page URL into “Edit Item” option or hide that option from specific list and add new custom action which will point to new layouts page, I already added new custom action into Edit Control block. But I am facing some of the challenges with other items.

Thank you very much for your time.

Thanks,
Sanket Shah

RupaliK said...

Thanks for the good article.

Here is the alternate solution without changing core.js:

Add below javascript to default.master page-

<script language="javascript">
function AddSendSubMenu(m,ctx)
{
return false;
}
</script>

Anonymous said...

Great Article !! Is there a way to send document as attachment along with the link in Send To Context menu?