Protect SharePoint Site Columns In Quick Edit View In SharePoint

Introduction

 
Sometimes, we get the requirement to allow users to do bulk updates on list items but want to restrict this to updating/editing a few of the columns.  We can't do this by default in SharePoint.
 

Solution

 
We need to use custom Javascript and inject it on a particular view of the list to protect the columns. Use the below script to add it on a quick edit view to protect columns. 
  1. < script type = "text/javascript" >  
  2.     // this is an array of the column names that need to protected in quick edit.   
  3.     //Use the column dispaly name here   
  4.     var updateViewerFields = ["Title""Status"];  
  5. (function updateView() {  
  6.     var currContext = {};  
  7.     currContext.Templates = currContext.Templates || {};  
  8.     currContext.Templates.OnPreRender = function(ctx) {  
  9.         for (j = 0; j < ctx.ListSchema.Field.length; j++) {  
  10.             var listSchema = ctx.ListSchema.Field[j];  
  11.             for (i = 0; i < updateViewerFields.length; i++) {  
  12.                 if (listSchema.DisplayName == updateViewerFields[i]) {  
  13.                     listSchema.AllowGridEditing = false;  
  14.                 }  
  15.             }  
  16.         }  
  17.     }  
  18.     SPClientTemplates.TemplateManager.RegisterTemplateOverrides(currContext);  
  19. })();   
  20. < /script>  
Save this script to a txt file and upload it in the site assets folder in SharePoint.
 
Add a content editor web part to a quick edit list view page and refer to the file and save the page.
 
Outcome
 
Defined columns in the script will be protected from editing in datasheet/quick edit view.
 
In my example here, I want to protect Title and Status column so I added only those columns in array but you can add as many as columns to this array object as you like.
 
Note
I have tested this on an SP 2013 environment.