0

i have a custom list with user who has only read permission goto the list view and select a item and press delete button in Keyboard then is Shows the below message and then when the user clicks ok then the message "Access denied" is displayed. How to Change this behaviour so that directly "Access denied" is displayed.

enter image description here

1
  • This is a OOTB SharePoint behavior. You cannot change it. Commented Mar 2, 2020 at 14:58

2 Answers 2

0

You could try to remove the check box from the list view so that user will not be able to select an item and delete it. modify current view, scroll to Tabular View => uncheck Allow individual item checkboxes => Save. This can prevent user delete row by delete key, but user cannot select multirow in table.

Or you could add a JavaScript in your list view page and we can disable the delete key, use the below code,

$(document).keydown(function(e) {
var element = e.target.nodeName.toLowerCase();
    if (e.keyCode === 46) {
        return false;
    }
});
</script>
0

As Karthik's reply, we can disable the "Delete" key press using the code below in list view.

Add the code into a script editor web part in the list view to achieve it.

<script src="https://code.jquery.com/jquery-1.12.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function() {
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
        OnPostRender: function(ctx) {
            $("table.ms-listviewtable tr").each(function (index, el) {
                el.addEventListener('keydown', function (event) { 
                    if (event.which == 46) { event.stopPropagation(); } 
                });
            });
        }
    });
});
</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.