I have added a document in a document library. I am trying to hide an option from ECB Menu

enter image description here

How do you hide any options from ECB Menu?

Update: Each item has a column "x" with different values. So, depending on those values, I would like to hide/show various ECB Menu options. To be clearer, item1 may show "Custom ECB option" whereas item2 may not show "Custom ECB option".


3 Answers 3


I hope it's not too late. I'll post anyway. It might be useful to others.

If your options' visibility is dependant on value of some column in respective item, I'd suggest you use JSOM with some tricks. I had used the same for one of my projects.

Firstly, assuming that you are deploying custom ECB menus via a module. If not, please do so. And associate these ECB options to a content type using RegistrationType as shown below, otherwise those options will keep showing everywhere.

<CustomAction Id="CustomActionID" RegistrationType="ContentType" RegistrationId="YOUR-CONTENTTYPE-ID"
    Title="Custom ECB Menu" >

    <UrlAction Url="YOUR URL"/>


After that in the same module add the jQuery and your own custom javascript/jQuery functions. Here's one problem in this - I had to add these in a layouts mapped folder because it didn't work for me when I added them in Style library and Site Assets. Then I tried with layouts and it worked so I didn't investigate much into that.

Here's how you would add the scriptlinks in the same module.

<CustomAction Location="ScriptLink" ScriptSrc="YOUR_LAYOUTS_MAPPED_FOLDER_NAME/jquery.min.js" Sequence="301"></CustomAction>
  <CustomAction Location="ScriptLink" ScriptSrc="YOUR_LAYOUTS_MAPPED_FOLDER_NAME/YOUR_JS_CODE_FILE.js" Sequence="302"></CustomAction>

Now, in YOUR_JS_CODE_FILE.js, you can add the code to get the list items and can check the desired column's value to decide whether to show or hide that option. It's no big task to get the items' column's value but you'll have to jump through hoops to hide/show the ECB options.


Here is the working solution -

Step 1 - Edit the Library Page and Add Script Editor Web Part .

Step 2 - Paste the Below Code in web part for hiding the required button from ECB Menu Item using the Button ID (Replace ID value after # ).

<style type="text/css">

li.ms-core-menu-item #ID_DeleteDocItem, .ms-core-menu-separator hr {



Note -Button Id can be found by Opening Core.js file (use ctrl+F to find the required ID) using the name of Menu Item . For eg if you want to hide Delete option , paste Delete in ctrl+F and get the reqiured ID .

Path for Core.js file - C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\LAYOUTS

Screen Shot : Hided CheckOut, Download & Delete option .

enter image description here


Add the following to a script editor web part and add that web part to the page containing the document lib webpart to hide options:

For a document lib:

.ms-core-menu-box li[text="Edit Properties"]

For a List :

    li[id^='mp'].ms-core-menu-item  a[title='My Custom ECB Menu Item'] {


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.