Hiding toolbar menu items in a Sharepoint list

A question I've been asked a couple of times recently is 'how to hide menu items on the list toolbars'

The problem faced by the clients was to hide the 'Edit in DataSheet' and 'Open in Explorer' commands.

The first attempt was to use a HideCustomAction element in a feature, this didnt work, so we had to look for an alternative solution.

Looking on the web provided two approached. Scott Hillier has a web part that can be placed on the page whcih will achieve the trick, but this would require modifying each existing library with the web part, plus ensuring that future library templates had the webpart definition applied.

Dipper Park has an alternative approach usig a custom control to hide complete sections of the menu. This was closer as it allowed all lists / libraries to be controlled.

In the end, we took the second option and created a custom control. The control contains a section of javascript to inspect the page objects & remove the individual menu items.

The script block was relatively simple & could be improved in future....

[code:js]

window.onload = HideMenuItem; 
function HideMenuItem()
{

var menuNodes = document.getElementsByTagName("menu");
var targetNode;
var targetViewNode;
var viewExplorerNode;
var dataSheetNode;
var explorerNode;
for (var i = 0; i < menuNodes.length; i++)
{
 
 var menuNode = menuNodes[i];
 if (menuNode.childNodes.length > 3)
 {
  if (menuNode.childNodes[0].id.indexOf("EditInGridButton") != -1)
  {
    targetNode = menuNode;
    dataSheetNode = menuNode.childNodes[0]; //is always node 0
    explorerNode = menuNode.childNodes[2]; //is always node 2
  }
  if (menuNode.childNodes[0].id.indexOf("DefaultView") != -1)
  {
   targetViewNode = menuNode;
   viewExplorerNode = menuNode.childNodes[2];
  }
 }
}
targetNode.removeChild(explorerNode);
targetNode.removeChild(dataSheetNode);

targetViewNode.removeChild(viewExplorerNode);

[/code]

 

After the script has run, the menus would look as per the following two images

 

 

It's important to note that in the above example, we are removing childNodes 0 & 2, really we should probably be checking for the location, rather than assuming they are 0 & 2

This could be taken a step further and wrapped into a feature. If a feature were to add some HTML onto the page (e.g. another menu item such as 'Print List') then the script could check for the existance of this menu item, then remove the childNodes.

The complete .ascx control is in the attachment

HideToolbars.zip (1.06 kb)

Currently rated 4.0 by 1 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Comments

May 21. 2010 13:55

online casino

Wow, fantastic blog! Will subscribe later on! Cheers!

online casino

May 21. 2010 18:35

Designer handbags

It looks like you spend a lot of effort and time on your blog. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work!

Designer handbags

May 21. 2010 20:39

loan modification

Man, I've been looking all over for this stuff. Thanks. Do you have any other sites other than Novotronix Blog - Hiding toolbar menu items in a Sharepoint list? I'd like a list of the best way to prepage for all of this and what is the best place to start? It'd be nice, no?

loan modification

August 5. 2010 19:51

Renaldo Alberding

Great article! You've made some very astute observations and I appreciate the time you've taken in your writing.

Renaldo Alberding

August 5. 2010 20:48

Loyd Robichaud

Thanks for sharing, I will bookmark and be back again

Loyd Robichaud

August 6. 2010 14:29

watch television on computer

This is not the first post I have read about that but you have explained it better than everyone else.

watch television on computer

August 7. 2010 05:45

Mauricio Vanostberg

Nice, i like your articles a lot and will be excited to read more

Mauricio Vanostberg

August 7. 2010 12:04

tinnitus remedies

Quite interesting blog post. Your site is promptly getting to be certainly one of my top features.

tinnitus remedies

August 9. 2010 13:05

Shawn Leishman@ warcraft 3 cd key

How's it going guys, you're honestly doing a awesome job here, I can readily say that it could have taken weeks, to do what you did in just a brief moment. I really appreciate all of the perspective you guys give.

Shawn Leishman@ warcraft 3 cd key

August 10. 2010 22:45

Jetta Strang

Terrific article, a bunch of superior facts. I'm going to point out to my girlftriend and ask them what they think.

Jetta Strang

August 12. 2010 16:28

Casinos online

Have try Playing Casino Online but now Play Online Poker that's the better choice.

Casinos online

August 13. 2010 10:30

Major Brazee

I was really pleased to find this web page.I wanted to thank you for this good read I definitely enjoying each little bit of it and I've you bookmarked to check out new stuff you post.

Major Brazee

August 14. 2010 08:54

Li Garnica

Can I make a suggestion? I believe youve obtained something excellent right here. But what in the event you added a couple links to a page that backs up what youre stating? Or possibly you can give us some thing to look at, anything that would connect what youre stating to some thing tangible? Just a suggestion.

Li Garnica

August 15. 2010 03:29

nike air max 90 online

I was very pleased to find this site.I wanted to thank you for this great read!! I definitely enjoying every little bit of it and I have you bookmarked to check out new stuff you post.

nike air max 90 online

August 15. 2010 22:27

max 90

Your blog seems interesting.Regards,Kevin.

max 90

August 17. 2010 04:30

Carmel Malveaux

Hi. Sweet layout you have there. I'm struggling to find the right theme for my own blog - where did you get this theme? is it free or paid? Many thanks.

Carmel Malveaux

August 17. 2010 13:18

Anissa Lamoreaux

Hi,I'm a professional pianist and I've made a stupid rule that allows me to take a 15 min break each and every 1 hour of practicing. Now, each and every break We have to accomplish some thing completely various, so mostly I go to Google and seek to the recommended last hour weblog. It is fun to perform something diverse and to understand about new points each and every single day. BTW, now I'm playing. Mozart. Your web site is good, I wish I could stay longer, but I've to have back to play... Up coming time I'll arrive to visit again.

Anissa Lamoreaux

August 17. 2010 14:40

vigrx

your site layout is very good

vigrx

August 19. 2010 00:14

Lawerence Postley

Hey, I just desired to let you know, I really like the written material on your site. But I am utilising Chromium on a machine running version 9.04 of Ubuntu as well as the seem and sense aren't really satisfying. Not a strong deal, I can still essentially go through the articles and search for info, but just desired to inform you about that. The navigation bar is kind of challenging to use while using config I'm running. Maintain up the superb function!

Lawerence Postley

August 21. 2010 21:28

discount fendi

There are certainly a lot of details like that to take into consideration. That is a great point to bring up. I offer the thoughts above as general inspiration but clearly there are questions like the one you bring up where the most important thing will be working in honest good faith. I don?t know if best practices have emerged around things like that, but I am sure that your job is clearly identified as a fair game.

discount fendi

August 25. 2010 07:14

Panda Global Protection Coupon

Wow, I believe what you said earlier is very true. Reflects what I'm experiencing. Properly since I am already right here, wonder if you'd be variety enough to change hyperlinks with my site. I might be inserting your link within the blogroll section, and I hope that our hyperlink trade can help us make our blogs better. Hope you'll be able to fulfill my humble request.

Panda Global Protection Coupon

August 25. 2010 18:32

ip-telephony

Thanks for this great post. The info I have gained from your blog is truly inspiring

ip-telephony

August 26. 2010 23:09

Christie Alperin

Thanks a good deal! I truly enjoyed reading this.Looking through these posts and the information you've provided I can appreciate that I still have a lot of things to learn. I will keep reading and keep re-visiting.

Christie Alperin

August 26. 2010 23:11

Clarence Abriola

Thank you also for introducing me to Intelligence on this site. You’re so kind and accommodating. I really appreciate how comfortable they made me feel.

Clarence Abriola

August 28. 2010 00:05

Adele Gartenmayer

What a wonderful idea. I am not totally sure if that is true, but who knows. Would you be kind enough to write another post, but from the opposing vantage point.

Adele Gartenmayer

August 28. 2010 00:07

Valentin Schwalbe

Thanks a good deal! I truly enjoyed reading this.Looking through these posts and the information you've provided I can appreciate that I still have a lot of things to learn. I will keep reading and keep re-visiting

Valentin Schwalbe

August 28. 2010 12:32

chat nude

Hello everybody. Just thought I’d drop a line. Lately I have become addicted to blogs I think. I will start reading a little and before I know it half the day is gone. Came upon this blog and I am just amazed how infinite the topics can be. Anyway, thanks from an information junkie.

chat nude

August 28. 2010 12:33

camgirls

You may have not intended to do so, but I think you have managed to express the state of mind that a lot of people are in. The sense of wanting to help, but not knowing how or where, is something a lot of us are going through.

camgirls

August 29. 2010 17:05

student driver sign

I was wondering if you ever considered changing the layout of your blog? Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could connect with it better. Youve got an awful lot of text for only having one or two images. Maybe you could space it out better?

student driver sign

August 30. 2010 15:35

bail bonds

Thanks for writing this. I really feel as though I know so much more about this than I did before. Your blog really brought some things to light that I never would have thought about before reading it. You should continue this, Im sure most people would agree youve got a gift.

bail bonds

August 31. 2010 06:32

Poker Casino Games

Pokercasinogames.org provide the best poker and casino games within best bonus.

Poker Casino Games

August 31. 2010 20:58

name tags

Greetings from California

name tags

September 1. 2010 07:19

Walker Bienkowski

great post! i'm bookmarking this!

Walker Bienkowski

September 1. 2010 09:24

How Much Does Christina Hendricks Weigh?

I'm getting a javascript error, is anyone else?

How Much Does Christina Hendricks Weigh?

September 1. 2010 09:28

Educational Consultant

An cool blog post right there mate . Cheers for the post .

Educational Consultant

September 1. 2010 09:59

AL Bases

If you could message me with a few pointers on how you made your blog look like this , I would be thankful.

AL Bases

September 1. 2010 10:08

starcraft 2 hotkeys

If you could email me with any hints & tips on how you made your site look this good, I'd appreciate it.

starcraft 2 hotkeys

September 1. 2010 12:01

Natural Remedies

When are you going to post again? You really entertain a lot of people!

Natural Remedies

September 1. 2010 12:02

Stock Picks

Amazing article, thanks, I will subscribe to you RSS now!

Stock Picks

September 1. 2010 12:02

advice on making money

I'm getting a browser error, is anyone else?

advice on making money

September 2. 2010 06:18

Refugio Wanker

great post! i'm bookmarking this!

Refugio Wanker

September 2. 2010 20:43

online flowers perth

I really liked your article. Keep up the good work.

online flowers perth

September 2. 2010 22:27

Krugerrand Price

wow, awesome post, I was searching what are the best registry cleaner and ready to pay to solve the problem. luckily i found your site by google, learned a lot, now i have got some idea on how to solve my problem. I've bookmark your site and also add rss. keep us updated.

Krugerrand Price

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading



 

Dilbert of the day