0

I'm adding a custom action on the context menu of the item using javascript CAMOpt function:

function Custom_AddListMenuItems(m, ctx)
{
CAMOpt(m,'View (new window)','javascript:window.open(\'DispForm.aspx?ID=' + currentItemID + '\');','/_layouts/images/LIST.GIF');
return false;
}

In the case I have a web page with different web parts, the code above updates the context menu for all web parts.

How I can apply the CAMOpt on a specific target menu of a specific web part only?

Thank you

  • 1
    Maybe you can loop through all the web parts on the current page and inside if condition compare the id of the webpart to your webpart's id? – Akhoy Aug 4 '15 at 20:34
  • thanks @uberz91 for your suggestion. It was not really the correct solution, but it gave me some "beta" to find the final answer to the question. – Emiliano Poggi Aug 5 '15 at 8:42
1

The Custom_AddListMenuItems injection point is called anytime the context menu is invoked on click event.

To apply a different menu on all web parts connected to the a specific list only, just make a check on the ctx list name as follows:

function Custom_AddListMenuItems(m, ctx)
{
    if(ctx.listName == "{0738B7FB-4C2E-4595-8CB3-0F9C039E281C}")
    {
        CAMOpt(m, ...);
        return false;
    }
}

To apply a specific context menu on the specific list web part only, you can check on the web part id:

if(ctx.clvp.wpid == "c4e47721-5325-4f06-9ce4-2076e87c9d51")
{
    // CAMOpt here
    return false;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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