2014-10-08

On my projects list I have a field called Project Title, this field has nothing to do with the Title from the list items, in fact I dont even use it, so if yo create a view where you show the Project Title, there wont be a link to the display form. You can however show the ribbon, select the item and click on Edit Item or on View Item, that is like 2 or 3 more clicks right?

This JS Link will fix it for us:

(function () { 

// Create object that have the context information about the field that we want to change it's output render 
var projectTeamContext = {}; 
projectTeamContext.Templates = {}; 
projectTeamContext.Templates.Fields = { 
// Apply the new rendering for Body field on list view 
"Project_x0020_Title": { "View": ProjectTitleTemplate} 
}; 

SPClientTemplates.TemplateManager.RegisterTemplateOverrides(projectTeamContext); 

})(); 

function ProjectTitleTemplate(ctx){
var projectTitleValue = ctx.CurrentItem[ctx.CurrentFieldSchema.Name]; 
var displayUrl = ctx.displayFormUrl + "&ID=" + ctx.CurrentItem.ID;
return "<a href='" + displayUrl + "'>" + ctx.CurrentItem.Project_x0020_Title + "</a>"; 
}

 

About the author 

Luis Valencia