列表的自定义操作按钮 [英] Custom action buttons for List
问题描述
我在内容查询Web部件中添加了自定义操作按钮,用于添加,编辑,复制,删除和附加,如下所示.
I have added custom action buttons in Content query webpart for add,edit,copy,delete and attach as shown below.
添加"操作之所以起作用,是因为仅添加newitem的URL非常简单,但是我希望使用其他操作,例如编辑",复制",删除"和添加".附加.
for Add action it is working as it is very simple to just add the url of the newitem but I want others actions like Edit,Copy,delete & attach.
谢谢
sal
推荐答案
我建议您使用OOTB自定义操作.
I suggest you use the OOTB custom actions.
如果您仍要使用自定义操作按钮,我们可以使用下面的代码行来获取选定的项目.
If you still want to use your custom actions buttons, we can use the following line of code to get selected item.
var items = SP.ListOperation.Selection.getSelectedItems();
然后对于编辑",我们可以使用URL"EditForm.aspx?ID = [ItemId]".
Then for "Edit", we can use URL "EditForm.aspx?ID=[ItemId]".
复制",我们可以基于选定的项目ID获取列表项目,然后使用带有jQuery Ajax的REST API添加新项目.
"Copy", we can get the list item base on selected item id, then add new item using REST API with jQuery Ajax.
附加",我们可以使用REST API将附件添加到列表项.
"Attach", we can add attachments to list item using REST API.
删除",我们还可以将REST API与jQuery一起使用以删除列表项.
"Delete", we can also use REST API with jQuery to delete list item.
以下文章供您参考:
使用REST API将附件添加到SharePoint 2013中的列表项
SharePoint 2013:使用jQuery Ajax使用REST API
最好的问候,
丹尼斯
这篇关于列表的自定义操作按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!