自定义列表中的SharePoint自定义上下文菜单出现在文件夹上,而不仅仅是文件上。

3
我创建了一个自定义列表,以下是列表模板:

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

我添加了一个自定义操作:

   <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"/>

这个上下文菜单既出现在文件上,也出现在文件夹上,我能否让我的上下文菜单仅在文件上出现?

3个回答

4
您可以在内容类型上注册操作,但这可能不适合您的情况?

3
我从未在代码或XML中找到如何实现此操作的方法,但我在JavaScript中成功实现了它。
我将以下代码添加到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>

不幸的是,该项总是出现在上下文菜单的第一位。


2
<CustomAction
Id="ContextMenu"
Location="EditControlBlock"
Title=Permissions"
**RegistrationType="ContentType"**
ShowInLists="FALSE"
ImageUrl ="~Site/_layouts/nks.PNG"
**RegistrationId="0x0101"**>
    <UrlAction Url="your URL"/>
</CustomAction>

<CustomAction Id="ContextMenu" Location="EditControlBlock" Title=Permissions" **RegistrationType="ContentType"** ShowInLists="FALSE" ImageUrl ="~Site/_layouts/nks.PNG" **RegistrationId="0x0101"**> <UrlAction Url="your URL"/> </CustomAction> - Ali

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接