可以将应用程序页面附加到特定列表
-
16-10-2019 - |
题
我有一个场景,我需要创建一个仅安装在特定列表的欧洲央行菜单上的应用程序页面。这可能吗?还是将元素文件与列表类型EG任务列表相关联的唯一方法?
解决方案
是的,可以做到这一点:创建欧洲央行项目菜单仅为列表。...更好地确定运行时可以放入欧洲央行菜单中有多少个项目。为此,您需要JavaScript技能。
SharePoint为我们提供了一些使用JavaScript添加自定义欧洲央行项目的钩子。此挂钩是JS函数: custom_addlistmenuitems(M,CTX). 。但是问题是如何在欧洲央行中添加动态项目?我使用的解决方案是实现 同步 AJAX调用自定义ASPX,该自定义ASPX返回带有项目及其动作的XML。这是代码:
<script language="javascript">
function Custom_AddDocLibMenuItems(m, ctx)
{
//debugger;
var request;
var url = ctx.HttpRoot +
"/_layouts/GetCommands.aspx?ListID=" + ctx.listName +
"&ItemID=" + currentItemID +
"&UserId=" + ctx.CurrentUserId +
"&DateTime=" + Date();
if ( window.XMLHttpRequest )
{
request = new XMLHttpRequest();
request.open("GET", url, false);
request.send(null);
}
else if ( window.ActiveXObject )
{
request = new ActiveXObject("Microsoft.XMLHTTP");
if ( request )
{
request.open("GET", url, false);
request.send();
}
}
if ( request )
{
var commands = request.responseXML.getElementsByTagName("Command");
// for each command found in the returned XML, extract the name,
// image Url and script, and a new menu item with these properties
for ( var i = 0; i < commands.length; i++ )
{
var cmdName = commands[i].getElementsByTagName(
"Name")[0].firstChild.nodeValue;
var imageUrl = commands[i].getElementsByTagName(
"ImageUrl")[0].firstChild.nodeValue;
var js = commands[i].getElementsByTagName(
"Script")[0].firstChild.nodeValue;
var addSep = commands[i].getElementsByTagName(
"AddSep")[0].firstChild.nodeValue;
CAMOpt(m, cmdName, js, imageUrl);
if (addSep == "True")
CAMSep(m);
}
// if at least one command was actually added, add a separator
if ( commands.length > 0 )
CAMSep(m);
}
// returning false makes SharePoint render the rest of the standard menu
return false;
}
function Custom_AddListMenuItems(m, ctx)
{
Custom_AddDocLibMenuItems(m, ctx);
}
</script>
该脚本必须放置在列表webpart旁边的WebPart中(在Ex的内容编辑器Web部件中。)
这个想法不是我的 这是原始文章. 。希望这会有所帮助。
其他提示
必须将其连接到列表模板(如果使用服务器端功能),则具有特定的ID。我建议您创建一个具有隐藏列表模板和列表实例的功能,然后将欧洲央行附加到该列表模板上。