1

I have a custom site column named "Item Number". now i want to force this column to be un-editable inside the Quick Edit grid. now when i try to edit the site column (Site Setting>> Site Column >>click on the column), the url will be as follow:-

http://..../_layouts/15/fldedit.aspx?field=ID1&Source=%2F%5Flayouts%2F15%2Fmngfield%2Easpx%3FFilter%3DAll%2520Groups 

which mean the field ID = ID1. so to be able to hide the column from all the Quick edit grid , i wrote the following JSLINK script (HideColumnsINGrid.js):-

(function () { var overrideContext = {}; overrideContext.Templates = overrideContext.Templates || {}; overrideContext.Templates.OnPreRender = function(ctx) { var statusField = ctx.ListSchema.Field.filter(function(f) { return f.ID === 'ID1'; }); if (statusField) { statusField[0].AllowGridEditing = false; } } SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideContext); })(); 

then i wrote the following powershell script to apply the above JSlink to the field as follow:-

 $web = Get-SPWeb http://vstg01 $field = $web.Fields["Item Number"] $field.JSLink = "Style%20Library/JS/HideColumnsINGrid.js" $field.Update($true ) 

now the power shell script did not raise any error , but the Item number can still be edited from the Qucik Edit ?so can anyone adivce on this please ?

Thanks

2
  • 1
    If your js file is being loaded in New/Edit form? Commented Jun 9, 2015 at 8:43
  • @KalpeshVaghela now i added "alert(12345);" inside the script but it did not get fire,, also the page source does not have any referecne to the script... but if i am not wrong the script is not supposed to load inside the new/edit forms it should fire if i am inside the quick edit grid ,, is this correct? Commented Jun 9, 2015 at 10:04

1 Answer 1

1

Here is your answer

(function () { var fieldContext = { Templates: { Fields: { ID1: { View: function (ctx, b) { b.AllowGridEditing = false; return ctx.CurrentItem.ID1; } } } } }; SPClientTemplates.TemplateManager.RegisterTemplateOverrides(fieldContext); })(); 

You need to apply that JSLink to view not in field.

2
  • so you mean i need to add this to the all the list's views, and also to any additional views ? this will not be a good approach as i have many views and i do not want to be editing them separately ,, i want to define this based on the item not based on the view,,and have the effect automatically inside all the views... what do u think ? Commented Jun 9, 2015 at 11:03
  • can you adivce on my comment please? Commented Jun 9, 2015 at 21:39

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.