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