Obviously, this is something I need to do just in certain circumstances (determined by the current contents of a list).

The reason I want to keep the action visible is to set its description to say something like "Once you add new items, this action will be active again".

Thanks in advance Josh

  • It will probably depend on where your custom action is going to land and on what version of the product (2007 or 2010). For instance, as GillouX stated, you can enable/disable Ribbons as such. For items somewhere else, i.e. Site Settings page, it will be different.
    – MBSurf
    Jun 23, 2011 at 18:03
  • Since MenuItemTemplate is in the Microsoft.SharePoint.WebControls namespace, and at first glance looks like a web control, I was hoping to find a .Enabled attribute. But no such luck.
    – Josh Korn
    Jun 23, 2011 at 21:36

3 Answers 3


It's far from the most elegant thing I've done, but it'll work for now.

The seed of the idea comes from this blog entry.

To make it work, I used a Content Editor webpart containing this jQuery snippet:

<script type="text/javascript">

   $("[text*='My Custom Action Text']").each(function() {
      $(this).attr('disabled', true);
      $(this).attr('onmenuclick', '');


In an IE-exclusive environment, the .disabled setting is sufficient to do exactly what's required. But it looks like the .disabled attribute isn't in the Firefox object model, so if it's necessary to make it function in the Firefox world, you also need the .onmenuclick line.

Firefox still doesn't grey out the item, but it renders the action null.


if you speak about a button in the Ribbon, the only way to enable/disable the button based on some rules is to defined in your CommandUIHandler the EnabledScript properties.

  • Ribbon? Not really 8-) We're talking a MOSS2007 Action item, I'm afraid.
    – Josh Korn
    Jun 23, 2011 at 17:27
  • you didn't specify it, my guess is that you are riding SP2010 :D
    – GillouX
    Jun 23, 2011 at 19:12

I would look at a couple of features that enabled / disabled your actions based on required criteria.

This link may be useful:


  • Won't work, unfortunately. The state of the list changes on the fly, so I guess I need to change the state of the MenuItemTemplate on the fly also.
    – Josh Korn
    Jun 23, 2011 at 21:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.