사용자 정의 목록의 SharePoint 사용자 정의 컨텍스트 메뉴는 파일뿐만 아니라 폴더에 나타납니다.
-
09-09-2019 - |
문제
여기에 사용자 정의 목록을 만들었습니다. 여기서 목록 템플릿이 있습니다.
<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}&ListItemID={ItemId}&Action=Copy"/>
이 문맥 메뉴는 파일과 폴더 모두에 나타납니다. 내 컨텍스트 memu가 파일에만 나타날 수 있습니까?
해결책 2
코드 나 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>
불행한 부작용 중 하나는 항목이 항상 컨텍스트 메뉴에서 가장 먼저 있다는 것입니다.
다른 팁
대신 콘텐츠 유형에 작업을 등록 할 수 있습니다. 그러나 그것은 당신의 상황에서 적합하지 않을 수 있습니까?
<CustomAction
Id="ContextMenu"
Location="EditControlBlock"
Title=Permissions"
**RegistrationType="ContentType"**
ShowInLists="FALSE"
ImageUrl ="~Site/_layouts/nks.PNG"
**RegistrationId="0x0101"**>
<UrlAction Url="your URL"/>
</CustomAction>
제휴하지 않습니다 StackOverflow