1

I want to disable the Title column from the Quick Edit grid, inside certain web-parts so i did the following steps:-

1- I went to a list view.

2- Edit the page

3- Edit the web part.

4- Under the "Miscellaneous" tab

5- I add a reference to the following JSLink:-

(function () {

      function registerRenderer() {
        var ctxForm = {};
        ctxForm.Templates = ctxForm.Templates || {};;
        ctxForm.Templates.OnPreRender = function(ctx) {
        var statusField = ctx.ListSchema.Field.filter(function(f) {
            return f.Name === 'Title';
        });
        if (statusField.length>0) {
            statusField[0].AllowGridEditing = false;
        }
    }
        ctxForm.Templates = {
            Fields : {
                'LinkTitle': { //------ Change Hyperlink of LinkTitle
                    View : function (ctx) {
                        if(ctx.CurrentItem.SiteAutomaticallyCreated != null && ctx.CurrentItem.SiteAutomaticallyCreated === 'Yes'){
                        var url = String.format('{0}{1}', "/Programmes/", ctx.CurrentItem.ID);
                        return String.format('<a href="{0}" onclick="EditItem2(event, \'{0}\');return false;">{1}</a>', url, ctx.CurrentItem.Title);
                        }
                        else
                        {
                            var url = String.format('{0}{1}', "/Programmes/Lists/Projects/DispForm.aspx?ID=", ctx.CurrentItem.ID);
                        return String.format('<a href="{0}" onclick="EditItem2(event, \'{0}\');return false;">{1}</a>', url, ctx.CurrentItem.Title);
                        }
                    }
                },
            }
        };
        SPClientTemplates.TemplateManager.RegisterTemplateOverrides(ctxForm);
    }
    ExecuteOrDelayUntilScriptLoaded(registerRenderer, 'clienttemplates.js');


})();

but the Title field will still be editable inside the quick edit grid, while the other part of my JS link (ctxForm.Templates) is working well. so can anyone adivce how i can disable the Title field on certain web parts using JSlink ?? as seems this part inside my JSLink is not working well:-

ctxForm.Templates.OnPreRender = function(ctx) {
        var statusField = ctx.ListSchema.Field.filter(function(f) {
            return f.Name === 'Title';
        });
        if (statusField.length>0) {
            statusField[0].AllowGridEditing = false;
        }
    }

Thanks

3
  • 1
    John...do you need the Title to show in other places? If you don't want it at all, what I normally do is create a content type and set that column to hidden.
    – jpollar
    Jan 3, 2017 at 22:04
  • @jpollar in my case the Title column will be set automatically inside a workflow .. so i am already hiding it inside the content type. but on the list views i want to show it ,, but i need to prevent users from changing its value by disabling it inside the quick edit grid.. hope this explain my problem in a better way for you??
    – John John
    Jan 4, 2017 at 0:42
  • Found something that might help.
    – jpollar
    Jan 8, 2017 at 2:18

1 Answer 1

1

John G,

Try something like this.

Reference: Disabling a column in Quick Edit

(function () {
    var overrideContext = {};
    overrideContext.Templates = overrideContext.Templates || {};
    overrideContext.Templates.OnPreRender = function(ctx) {
        var statusField = ctx.ListSchema.Field.filter(function(f) {
            return f.Name === 'LinkTitle';
        });
        if (statusField) {
            statusField[0].AllowGridEditing = false;
        }
    }
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideContext);
})();
2
  • i think the internal name for the column is LinkTitle and not Title.. please update your answer so i can accept it.. thank
    – John John
    Jan 15, 2017 at 1:43
  • wish granted. ;)
    – jpollar
    Jan 15, 2017 at 2:03

Your Answer

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

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