繁体   English   中英

SharePoint 2013 - 如何将按钮添加到按下时打开列表表单的页面?

[英]SharePoint 2013 - How do I add a button to a page that opens a list form when pressed?

我目前在 SharePoint 2013 中工作,想知道是否有办法在主页上创建一个按钮,当按下该按钮时,会在模式窗口中打开一个列表表单? (或在非模态窗口中)。

我了解使用“嵌入代码”对按钮进行编码的方法; 但是,它似乎不允许我将它链接到列表表单,或者编辑按钮的实际作用。

例子:

1. 员工登陆主页,想通过公司发起采购申请。

2. 员工单击标有“单击此处提交采购申请”的按钮。

3. 单击后,采购申请表从采购申请清单(预先创建)中打开。

谢谢您的帮助!

您可以在 CEWP 中使用类似的内容重定向到新项目表单:

<button onclick="formRedirect(); return false;">New Form</button>
<script> 
    function formRedirect() { 
        window.location = "/test/Lists/LinkList/NewForm.aspx" 
    } 
</script>

要以 Modal 形式显示它,您需要使用 NewItem2 JS 函数:

<button onclick="NewItem2(event, &quot;https://Your.SP.Site/_layouts/15/listform.aspx?PageType=8&amp;ListId=%7B59E6FE0C%2D02C6%2D4B00%2D9B6A%2D87116A2DF594%7D&amp;RootFolder=&quot;); return false;">New Form</button>

要使其工作,您将需要按钮所在页面上的列表 Web 部件,但可以通过将 th chrome 设置为 none 并将其最小化来隐藏它。 您可以从要显示的列表中的新项目按钮复制该功能,它存储为“OnClick”属性。

我知道我迟到了,但我只是想出了如何为文档库的“上传文档”执行此操作。 我花了一段时间,但我通过使用 F12 的反复试验偶然发现了它。 我将为“列表和库”表单提供两个脚本。

清单:

<a href="#" onclick="openDialog('YourSiteURL/Lists/YourListName/NewForm.aspx');">
   <img src="YourSiteImageURL" alt="NameofYourImage">
</a>

<script>
  function openDialog(pageUrl) { 
  var options = {
  url: pageUrl,
  title: 'NameofYourForm', /* Enter the name you want for your form */
  allowMaximize: false,
  showClose: true,
  width: 1225, /* Modify for your needs */
  height: 800 /* Modify for your needs */
};
  SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);       
}
</script>

对于图书馆:

这是与按钮一起使用的:

<a class="ms-addnew" id="idHomePageNewDocument" onclick='NewItem2(event, "YourSiteURL/_layouts/15/Upload.aspx?List={YourListID}&amp;RootFolder="); return false;' href="YourSiteURL/_layouts/15/Upload.aspx?List={SameListID}&amp;RootFolder=" target="_self" data-viewctr="702">
   <img src="URLforYourButtonImage" alt="NameofYourButton">
</a>

这是用于文本:

<a class="ms-addnew" id="idHomePageNewDocument" onclick='NewItem2(event, "YourSiteURL/_layouts/15/Upload.aspx?List={YourListID}&amp;RootFolder="); return false;' href="YourSiteURL/_layouts/15/Upload.aspx?List={SameListID}&amp;RootFolder=" target="_self" data-viewctr="702">Add document
</a>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM