Disabling a column in Quick Edit
By Anatoly Mironov
In my project I have a column called Request Status. This column is not shown in any forms, meaning users should not edit, because it is controlled through the app. Nevertheless it is editable in the Quick Edit. Yesterday I wrote about jsgrid in my blog. Now comes more. Today I’ll share a little practical solution how one can disable editing a field in Quick Edit. The field is edited in jsgrid, but to disable it, we only have set the property called AllowGridEditing to false on our column (not even touching the heavy jsgrid api). We can do in the OnPreRender event in our Client Side Rendering (CSR) registration. Having the context object we have access to the Fields (ContextInfo.ListSchema.Field): [code language=“javascript” highlight=“6,9”] (function () { var overrideContext = {}; overrideContext.Templates = overrideContext.Templates || {}; overrideContext.Templates.OnPreRender = function(ctx) { var statusField = ctx.ListSchema.Field.filter(function(f) { return f.Name === ‘Request_x0020_Status’; }); if (statusField) { statusField[0].AllowGridEditing = false; } } SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideContext); })(); [/code] Another way is to implement the display form: [code language=“javascript”] (function () { var view = function (ctx, field) { if (ctx.inGridMode) { field.AllowGridEditing = false; } return window.RenderFieldValueDefault(ctx); }; var overrideContext = {}; overrideContext.Templates = overrideContext.Templates || {}; overrideContext.Templates.Fields = { ‘Request_x0020_Status’: { ‘View’: view } }; SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideContext); })(); [/code]
Comments from Wordpress.com
Niki - Dec 0, 2014
Hi! Thanks for sharing this script, very usefull. My question is, how can I set the DefaultValue in the DataGrid with same field where I set AllowGridEtditing to false? Thanks, Niki
Hi, Thanks for nice stuff , I want to enable editing for new item for existing item i want to disable editing your code disabled fully.plz help
Hi, you have to “find” all columns that matter and set AllowGridEditing to false.Use HTML5 javascript functions filter and forEach.
Please help me with multiple column disabling with jslink in quick edit
Hi, you can create different functions for new and edit. In the edit you can disable editing in Quick Edit.
You can try this:
return window.RenderFieldValueDefault(ctx);
```But in some cases it doesn't work. Then you need to return the field value:
return ctx.CurrentItem[ctx.CurrentFieldSchema.Name] || ‘’;
<hr />
####
[Disable a site collection column inside lists's quick edit grid | Question and Answer](http://qandasys.info/disable-a-site-collection-column-inside-listss-quick-edit-grid/ "") - <time datetime="2015-08-11 22:00:33">Aug 2, 2015</time>
\[…\] SharePoint 2013 supports disabling a site collection column inside the list’s quick edit grid link. so I tried to apply the same inside a custom list. So I wrote the following JSLink \[…\]
<hr />
####
[Renuka]( "renukanadgir@gmail.com") - <time datetime="2015-11-05 07:41:29">Nov 4, 2015</time>
Hi, can you please help me to set "AllowGridEditing" to false for multiple columns? I tried repeating the code for "Request Status", but it doesn't seem to work.
<hr />
####
[wasif]( "wasifbinrashid@gmail.com") - <time datetime="2015-08-24 14:26:51">Aug 1, 2015</time>
how can i set AllowGridEditing to false for multiple columns ?
<hr />
####
[VJ]( "kvk_victor@rediffmail.com") - <time datetime="2015-12-07 23:37:12">Dec 1, 2015</time>
Hi Thanks for the help ful post, I am trying to sort values in multi choice field in quick edit, can you please help, I tried to write function to sort but it doesn't apply to values in the columns
<hr />
####
[Drew Griffin](http://nationalparcel.com "dgriffin@nationalparcel.com") - <time datetime="2015-12-28 22:53:42">Dec 1, 2015</time>
Is this script inserted in a CEWP above the quick edit web part or is it inserted somewhere else into existing code using SharePoint Designer? Or other method. Thanks for your help.
<hr />
####
[SharePoint 2013 – Disable multiple columns in Quick Edit | Why Didn't I Think of That?](https://wditot.wordpress.com/2016/02/02/sharepoint-2013-disable-multiple-columns-in-quick-edit/ "") - <time datetime="2016-02-02 17:19:12">Feb 2, 2016</time>
\[…\] Anatoly Mironov, has another post that explains how to lock a single field in the Quick Edit. ( http://chuvash.eu/2014/11/28/disabling-a-column-in-quick-edit/ \[…\]
<hr />
####
[Anurag](http://ajaxfire.wordpress.com "garuna1987@gmail.com") - <time datetime="2016-02-02 17:21:28">Feb 2, 2016</time>
An update for multiple columns, hope this helps others : https://wditot.wordpress.com/2016/02/02/sharepoint-2013-disable-multiple-columns-in-quick-edit/
<hr />
####
[Anatoly Mironov](http://chuvash.eu "mirontoli@gmail.com") - <time datetime="2016-02-02 17:23:24">Feb 2, 2016</time>
Great! Thanks for sharing! Now your blog post will be linked. I read your blog. Good stuff. Keep posting!
<hr />
####
[Jan Marek]( "jan_marek@centrum.cz") - <time datetime="2016-02-10 10:40:13">Feb 3, 2016</time>
Hi, thanx for this. But it didn´t quite work for me. This is what I loaded as a text file into the documents library (library has check out required). I assigned rights for that file just for me (the list views were created by others as public views but I have site collection admin rights on that SP site and placed the URL into CEWP in that view and clicked stop Editing. So here is the code I used var updateViewerFields=\["Actual Completion Date","Date of Update", "Start Date"\]; (function updateView() { var overrideContext = {}; overrideContext.Templates = overrideContext.Templates || {}; overrideContext.Templates.OnPreRender = function(ctx) { for(j=0; j<ctx.ListSchema.Field.length; j++) { var f = ctx.ListSchema.Field\[j\]; for(i=0;i<updateViewerFields.length;i++){ if(f.DisplayName == updateViewerFields\[i\]){ f.AllowGridEditing=false; } } } } SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideContext); })(); but the columns are still editable. Any thoughts please? Many thanx again
<hr />
####
[Anatoly Mironov](http://chuvash.eu "mirontoli@gmail.com") - <time datetime="2016-02-11 07:28:21">Feb 4, 2016</time>
You have to overrride the "View" behaviour of the fields. f.AllowGridEditing outside "View" override will not affect the field.
<hr />
####
[JV]( "jvillamar@flushingbank.com") - <time datetime="2016-06-03 15:59:33">Jun 5, 2016</time>
Why not just use a calculated column? What I did was to create and set a calculated column to equal the value of the column I wanted to disable. Then I added the calculated column to the view of the Quick Edit. Calculated columns are not editable.
<hr />
####
[Chris Hernandez]( "lumpypuppy@gmail.com") - <time datetime="2016-08-13 16:54:30">Aug 6, 2016</time>
Dear Anatoly, do you know how I can disable bulk edit in datasheet/quick edit view? Chris🤔
<hr />
####
[Farhan Aslam]( "s.farhanaslam@gmail.com") - <time datetime="2017-05-04 08:56:02">May 4, 2017</time>
Thanks
<hr />
####
[Saurabh shankar]( "shankar.saurabh08@gmail.com") - <time datetime="2017-06-22 18:46:37">Jun 4, 2017</time>
Hi Anatoly I am trying to implement a scenario in which I want to restrict the users to select the choice options present with choice field in Quick edit more. For eg.- choice contains month names - Jan, Feb, March, Apr etc.. I want them to have only month options which is next three months. Any help is appreciated.
<hr />
####
[SShankar](http://shankarsaurabh08.wordpress.com "shankar.saurabh08@gmail.com") - <time datetime="2017-06-22 18:47:44">Jun 4, 2017</time>
Hi Anatoly I am trying to implement a scenario in which I want to restrict the users to select the choice options present with choice field in Quick edit more. For eg.- choice contains month names - Jan, Feb, March, Apr etc.. I want them to have only month options which is next three months. Any help is appreciated.
<hr />