使用 Custom_AddDocLibMenuItems 的 SPDocumentLibrary 菜单项的顺序

发布于 2024-08-02 07:04:47 字数 828 浏览 3 评论 0原文

我正在将自定义上下文菜单项添加到 SharePoint 中 SPDocumentLibrary 列表中的文档(而不是文件夹)。以下代码有效,但总是在上下文菜单的顶部添加我的自定义菜单项,这是我不想要的。我猜测 CAMOpt 中的最后一个参数是一个定义顺序的序列号,但它似乎没有任何效果。有谁知道是否可以将自定义上下文菜单项添加到列表底部?

function Custom_AddDocLibMenuItems(m, ctx) {
    var otype = currentItemFSObjType = GetAttributeFromItemTable(itemTable, "OType", "FSObjType");
    if (otype != 1) {
        var itemId = GetAttributeFromItemTable(itemTable, "ItemId", "Id");
        var listId = ctx.listName;

        var action = 'Go_To_Page("' + ctx.HttpRoot + '/_layouts/custom/PAGES/mycustompage.aspx?ListId=' + listId + '&ListItemID=' + itemId + ');';
        CAMOpt(m, 'Custom Menu Item', action, '/_layouts/custom/IMAGES/action.gif', '', 110);
        CAMSep(m);
    }
    return false;
}

function Go_To_Page(page) {
    window.location = page;
}

I'm adding a custom context menu item to documents (and not folders) in a SPDocumentLibrary list in SharePoint. The following code works, but always adds my custom menu item at the top of the context menu, which I don't want. I was guessing that the final parameter in CAMOpt was a sequence number that would define the order, but it doesn't seem to have any effect. Does anyone know if it's possible to add a custom context menu item to the bottom on the list?

function Custom_AddDocLibMenuItems(m, ctx) {
    var otype = currentItemFSObjType = GetAttributeFromItemTable(itemTable, "OType", "FSObjType");
    if (otype != 1) {
        var itemId = GetAttributeFromItemTable(itemTable, "ItemId", "Id");
        var listId = ctx.listName;

        var action = 'Go_To_Page("' + ctx.HttpRoot + '/_layouts/custom/PAGES/mycustompage.aspx?ListId=' + listId + '&ListItemID=' + itemId + ');';
        CAMOpt(m, 'Custom Menu Item', action, '/_layouts/custom/IMAGES/action.gif', '', 110);
        CAMSep(m);
    }
    return false;
}

function Go_To_Page(page) {
    window.location = page;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

捶死心动 2024-08-09 07:04:47

是否有任何原因导致您无法使用自定义操作功能?例如,使用类似于以下内容的功能元素代码,但修改 CustomAction 的序列号元素 来定位菜单选项:

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <CustomAction
        Id="DoSomething"
        RegistrationType="ContentType"
        RegistrationId="0x0101"
        Location="EditControlBlock"
        Sequence="10001"
        ImageUrl="/_layouts/images/action.gif"
        Title="Do Something">
        <UrlAction Url="~site/_layouts/custom/PAGES/mycustompage.aspx?ListItemID={ItemId}&ListId={ListId}" />
    </CustomAction>
</Elements>

设置内容类型应确保该功能不适用于文件夹。如果由于某种原因它显示并且似乎无法禁用它,您可以使用 JavaScript/jQuery 从文件夹中隐藏菜单选项。

Is there any reason why you aren't able to use a custom action feature? For example use feature element code similar to the following but amend the Sequence number of the CustomAction element to locate the menu option:

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <CustomAction
        Id="DoSomething"
        RegistrationType="ContentType"
        RegistrationId="0x0101"
        Location="EditControlBlock"
        Sequence="10001"
        ImageUrl="/_layouts/images/action.gif"
        Title="Do Something">
        <UrlAction Url="~site/_layouts/custom/PAGES/mycustompage.aspx?ListItemID={ItemId}&ListId={ListId}" />
    </CustomAction>
</Elements>

Setting the content type should ensure the feature doesn't apply to folders. If for some reason it is showing and there appears to be no way to disable it, you could use JavaScript/jQuery to hide the menu option from folders.

温柔一刀 2024-08-09 07:04:47

在包含用户控件的功能的元素 XML 中,在其中添加序列:

Control Id="AdditionalPageHead"
       ControlSrc="~/_ControlTemplates/blah/blah.ascx" Sequence="229"

In the elements XML for your feature where you include the User Control, add the sequence there:

Control Id="AdditionalPageHead"
       ControlSrc="~/_ControlTemplates/blah/blah.ascx" Sequence="229"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文