This SharePoint tutorial, we will discuss, how to enable or disable delete icon from the ribbon on SharePoint list item selection based on the logged-in user using CSOM or REST API services using jQuery.
The scenario is to disable the delete icon in the ribbon on the List item selection. But when any user logs into the SharePoint site the items created by him should have the delete option on them when only one selection is there.
This can be performed using custom Permission Level with Delete permission removed and item-level or folder-level permissions, but this can cause you a lot of problems managing the broken inheritance of permissions. Or you could create a SharePoint event handler to prevent the deletion of that item but the best way to do this is by using jQuery/ CSOM/ REST.
I have offered a code demo about how to disable the delete icon in the ribbon on List Item Selection.
Enable or Disable Delete Icon in Ribbon on SharePoint List Item Selection
Here are the steps to enable or disable Delete icon from the ribbon on SharePoint list item selection in SharePoint 2013/2016.
Step 1: Navigate to your SharePoint 2013 site.
Step 2: From this page select the Site Actions | Edit Page.
Edit the page, go to the “Insert” tab in the Ribbon and click the “Web Part” option. In the “Web Parts” picker area, go to the “Media and Content” category, select the Script Editor web part and press the “Add button”.
Without any list item Selection to disable delete icon in the ribbon on List.
With Multi list item Selection to disable delete icon in the ribbon on List.
With Single list item Selection (Logged in) to unable delete icon in the ribbon on List.
You may like following SharePoint customization tutorials:
- How to show/hide columns based on value of SharePoint radio button
- Change column ordering in list forms in SharePoint Online/2013/2016
- How to remove/hide default title column from SharePoint Online list (modern/Classic)
- Different ways to create auto-increment column in SharePoint 2013/2016/Online list
- Different ways to hide/disable quick edit in a list in SharePoint 2013/2016/Online
- Change default list view style using CSS in SharePoint Online/2016/2013
- Make Title field read-only in SharePoint list edit form using JSLink
- Add items from CSV file to SharePoint Online List using PowerShell in CSOM
- Hide attach file button in SharePoint
- Delete SharePoint List Item attachment using Rest API
I have tried to disable/enable the delete icon in the ribbon on List Item Selection, which would provide you greater flexibility in user interaction on the application. I have achieved this using CSOM/REST API and jQuery in SharePoint 2013. I hope this article is helpful to you and I expect you to revert back to it in case of any queries.
Solutions. I am currently working on Sharepoint 2010, MOSS 2007, Sharepoint 2013,Sharepoint 2013 App Dev, C#, ASP.NET, and SQL Server 2008.