views:

1150

answers:

2

I have created a custom list here is the List Template:

<ListTemplate Name="CustomDocumentLibrary"
            DisplayName="Document Library"
            Description=""
            BaseType="1"
            Type="10101"
            OnQuickLaunch="TRUE"
            SecurityBits="11"
            Sequence="110"
            Image="/_layouts/images/itdl.gif"
            DocumentTemplate="101" />

I have added a custom Action:

   <CustomAction
Id="1611D96C-ABBD-4021-9183-60D8440BEB95"
Location="EditControlBlock"
Title="Send to Document Management"
ImageUrl="/_layouts/images/cmCopy.gif"
RegistrationType="List"
RegistrationId="10101">
<UrlAction Url="~site/Lists/DocumentLibrary/Forms/SendToDM.aspx?ListId={ListId}&amp;ListItemID={ItemId}&amp;Action=Copy"/>

This context menu appears on both files and folders, is it possible for my context memu to appear on files only?

+3  A: 

You can register the action on the content type instead. But that might not be suitable in your situation?

JMD
+3  A: 

I never figured out how to do this in code or XML but I got it working in JavaScript.
I added the following code to the AllItems.aspx:

<script type="text/javascript">
    function Custom_AddDocLibMenuItems(m, ctx) {
        var otype = currentItemFSObjType = GetAttributeFromItemTable(itemTable, "OType", "FSObjType");
        if (otype != 1) { // 1=folder
            var itemId = GetAttributeFromItemTable(itemTable, "ItemId", "Id");
            var listId = ctx.listName;
            var action = 'Go_To_Page("' + ctx.HttpRoot + '/_layouts/MyPage.aspx?ListId=' + listId + '&ListItemID=' + itemId + '");';
            var option = CAMOpt(m, 'Do Something', action, '/_layouts/IMAGES/10.gif', '', 1110);
            option.id = "ID_Do_Something";
        }
        return false;
    }

    function Go_To_Page(page) {
        window.location = page;
    }
</script>

One unfortunate side effect is the item is always first in the context menu.

Cube Pirate