3

我已經在這裏創造一個自定義列表是列表模板:的SharePoint自定義上下文菜單出現在文件夾中,而不僅僅是文件

<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

我從來沒有想過如何在代碼或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> 

一個不幸的副作用是該項總是首先在上下文菜單。

4

您可以改爲在內容類型上註冊操作。但是這可能不適合你的情況?

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

\t \t \t Ali 2010-12-16 08:11:11

相關問題