Logo 
Search:

MOSS Forum

Ask Question   UnAnswered
Home » Forum » MOSS       RSS Feeds

Hide Context Menu of a Particular Form Library

  Asked By: Caitlin    Date: Aug 30    Category: MOSS    Views: 4657

Is it possible to hide a context menu or contezt menu items for one
particular form library in my MOSS site?

Share: 

 

6 Answers Found

 
Answer #1    Answered By: Gail Richmond     Answered On: Aug 30

You can use a Web scoped HideCustomAction feature to do this. Do you
need an example?

 
Answer #2    Answered By: Ramona Solis     Answered On: Aug 30

Can you please pass on the example????

 
Answer #3    Answered By: Harvey Blankenship     Answered On: Aug 30

I don't think a HideCustomAction will do what
you want. You could use this to remove a menuitem from all libraries,
but not a specific library. I suspect you would need to write a
Javascript that would find the ID of the specific menu  item and set its
display to none.

 
Answer #4    Answered By: Xiomara Blanchard     Answered On: Aug 30

While I have examples on how to hide  options on the Site Settings page,
I don't have an example of how to hide menu  options. In fact, I
attempted to generate one but HideCustomOptions doesn't seem to have the
necessary options to make it happen. So, I created a small script that I
placed into a Content Editor Web Part (CEWP) just _below_ the listview
Web Part which worked well for me. Here is my JavaScript to hide the
Connect to Outlook option on a Contact list:

<script type="text/javascript">
try
{
//Get all the menu options on the current page
var menuitems = document.getElementsByTagName("ie:menuitem");
var menuitem;

//Iterate the options to find the option(s) to hide
for (var i = 0; i < menuitems.length; i++)
{
menuitem = menuitems(i);

//Find and hide the Connect to Outlook menu option
if (menuitem.id.indexOf("OfflineButton") > 0)
{
menuitem.hidden = true;
break;
}
}
}
catch(e)
{
window.status = e.message;
}
</script>




If you just want to see the IDs of the options that you _could_ hide,
you can insert this JavaScript.

<script type="text/javascript">
try
{
//Get all the menu options on the current page
var menuitems = document.getElementsByTagName("ie:menuitem");

for (var i = 0; i < menuitems.length; i++)
{
document.write(menuitems(i).id + " ");
}
}
catch(e)
{
window.status = e.message;
}
</script>

 
Answer #5    Answered By: Rosemarie Cervantes     Answered On: Aug 30

A lot cleaner than the code I was writing. I'd like to
suggest some changes mainly for compatibility with FireFox.

I modified this first script to run after the page was loaded otherwise it
missed menu  items rendered after the CEWP. Also FireFox seems to need array
syntax to be [i] and not (i).

<span id="customOutput"></span>
<script type="text/javascript">
_spBodyOnLoadFunctionNames.push("LocateMenuItems");
function LocateMenuItems()
{
var output = "";
try
{
//Get all the menu options on the current page
var menuitems = document.getElementsByTagName("ie:menuitem");
for (var i = 0; i < menuitems.length; i++)
{
output += menuitems[i].id + " ";
}
}
catch(e)
{
output = e.message;
window.status = e.message;
}

document.getElementById('customOutput').innerHTML = output;
}
</script>

For the second script FireFox won't recognize the menuitem.hidden property.
Changing it to menuitem.setAttribute("hidden", true) made it work the same in
both browsers.

<script type="text/javascript">
_spBodyOnLoadFunctionNames.push("HideMenuItems");
function HideMenuItems()
{
HideMenuItemByServerId("EditInGridButton");
HideMenuItemByServerId("AddColumn");
HideMenuItemByServerId("ExportToSpreadsheet");
}
function HideMenuItemByServerId(itemName)
{
try
{
//Get all the menu options on the current page
var menuitems = document.getElementsByTagName("ie:menuitem");
var menuitem;
//Iterate the options to find the option(s) to hide
for (var i = 0; i < menuitems.length; i++)
{
menuitem = menuitems[i] ;
//Find and hide  the menu option
if (menuitem.id.indexOf(itemName) > 0)
{
menuitem.setAttribute("hidden", true);
break;
}
}
}
catch(e)
{
window.status = e.message;
}
}
</script>

Other than those small changes it worked perfectly. It's too bad
HideCustomAction doesn't work for these.

 
Answer #6    Answered By: Manan Kadu     Answered On: Aug 30

I put the solution together rather
quickly when I realized that HideCustomAction wasn't going to work.

I typically use square bracket syntax so it's odd that I didn't use it
here; especially since C# uses square brackets and I use that language
all the time...

 
Didn't find what you were looking for? Find more on Hide Context Menu of a Particular Form Library Or get search suggestion and latest updates.




Tagged: