javascript 从 SharePoint 2013 列表中删除编辑或新建项目按钮

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22399648/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 23:03:57  来源:igfitidea点击:

Removing edit or new item button from a SharePoint 2013 list

javascriptsharepointsharepoint-2010sharepoint-2013

提问by user3313941

I am having a list in sharepoint 2013. In one scenario I want the user to just enter a new item into a sharepoint list without editing any previous items.Whereas, in second scenario I just want the user to edit a list without being able to add any new item.

我在 sharepoint 2013 中有一个列表。在一种情况下,我希望用户只需将新项目输入到 sharepoint 列表中,而无需编辑任何以前的项目。而在第二种情况下,我只希望用户编辑列表而不能添加任何新项目。

From what I explored this is not posssible using any out of the box feature.

根据我的探索,使用任何开箱即用的功能是不可能的。

The four .aspx files newform, displayform, editform and allitems form don't seem to contain any option for resolving this.

四个 .aspx 文件 newform、displayform、editform 和 allitems 表单似乎不包含任何解决此问题的选项。

Does it require using any javascript code? How can it be done?

它需要使用任何 javascript 代码吗?怎么做到呢?

http://i.stack.imgur.com/pVEIm.png

http://i.stack.imgur.com/pVEIm.png

回答by Unnie

Just a tweak , create 2 custom permission levels. First one, has rights to add new/View item but no Edit/Delete item permissions. Second, level will have permission to edit item but no permission to add item. Try assigning the user these 2 permission level according to your scenarios, ie Give user first permission level when you want him to only add items and remove first and assign only second permission level when you want user to only edit item.

只需调整一下,创建 2 个自定义权限级别。第一个,有权添加新/查看项目但没有编辑/删除项目权限。其次,级别将具有编辑项目的权限,但没有添加项目的权限。尝试根据您的场景为用户分配这 2 个权限级别,即,当您希望用户仅添加项目并首先删除时给予用户第一权限级别,而当您希望用户仅编辑项目时仅分配第二权限级别。

回答by zeppaman

If yoy want to remove "add new" and "edit" feature, simply set "Toolbar Type" to "No Toolbar"

如果要删除“添加新”和“编辑”功能,只需将“工具栏类型”设置为“无工具栏”

回答by George TU

For your second scenario, an out of the box workaround: To allow users to only edit the list items without the option to add new items you can setup a public view with any grouping (this disables Quick Edit), then add a "mandatory field" (I use row #) that will not be visible in any public view, edit the "edit item" form with InfoPath and remove the "mandatory field". Even if users try to add a new item they will not be able to save, only edit existing items. Simple and doesn't require any coding of any kind nor permissions.

对于您的第二种情况,开箱即用的解决方法:要允许用户仅编辑列表项而不选择添加新项,您可以设置具有任何分组的公共视图(这会禁用快速编辑),然后添加“必填字段"(我使用第 # 行)在任何公共视图中都不可见,使用 InfoPath 编辑“编辑项目”表单并删除“必填字段”。即使用户尝试添加新项目,他们也无法保存,只能编辑现有项目。简单,不需要任何类型的编码或权限。