none
How I can disable a column inside the Quick Edit Grid using a JSLINK linked to my WebPart RRS feed

  • Question

  • 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 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




    • Edited by johnjohn11 Tuesday, January 3, 2017 6:14 PM
    Tuesday, January 3, 2017 4:54 PM

Answers

  • Hi John,

    As I tested in my environment, to disable the title field in Quick Edit mode, we need to set the field name to "LinkTitle" instead of "Title" like below:

    (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);
    })();

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    • Marked as answer by johnjohn11 Wednesday, January 4, 2017 5:21 PM
    Wednesday, January 4, 2017 8:44 AM

All replies