Ok, when I do as suggested by @users1100
This is the result I get, the column names goes away totally, and Title is still not acting as an url/linked to document.
Ok, when I do as suggested by @users1100
This is the result I get, the column names goes away totally, and Title is still not acting as an url/linked to document.
You need to apply JSLink for the view.
Below is the code which you can add it to JSLink:
(function () {
var overrideNameField = {};
overrideNameField.Templates = {};
// Title field will rediect to the last major version of the document.
overrideNameField.Templates.Fields = {
"Title": { "View": overrideNameFieldTemplate }
};
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideNameField);
})();
function overrideNameFieldTemplate(ctx) {
var title = ctx.CurrentItem.Title;
var fileRef = ctx.CurrentItem["FileRef"];
var fileLeafRef = ctx.CurrentItem["FileLeafRef"];
// here the url should be of your document library. In my case it was Pages library.
var url = _spPageContextInfo.webAbsoluteUrl + "/Pages/" + fileLeafRef;
if (title) {
return "<a href='"+ url + "'>"+ title + "</a>";
}
else {
return "<a href='" + fileRef + "'>" + fileLeafRef + "</a>";
}
}
Hope this helps.!
You cannot achieve this OOB, because if you go to EditView page from list settings you will not find any options like Title(Linked to Document) but just Title.
Also do not choose to edit webpart, this is not the best practice. And instead of solving your problem will become part of your problem in maintaining it.
JSLink is the best possible option to choose. Because its a JavaScript file which can be source controlled, and easily deployed on the Production environment.
Another solution would be to do this using workflow. Create a hyperlink column and update it from the workflow.
Workflow steps:
Create a workflow and build a dynamic string in the format {url}, {description}. (Should be a space after ,). You can get the url by using the Encoded Absolute URL property of the current item. For description, you can get the current item title. Update the hyperlink column using the string created above ({url}, {description}) and show in view.
This won't update the Name field directly but you'll get what you want. If you are not well versed in JS, this would be worth looking at.
Sorry, I have this weird mental condition where I rewrite JavaScript because it just reads better and processes faster.
This
function overrideNameFieldTemplate(ctx) {
var title = ctx.CurrentItem.Title;
var fileRef = ctx.CurrentItem["FileRef"];
var fileLeafRef = ctx.CurrentItem["FileLeafRef"];
// here the url should be of your document library. In my case it was Pages library.
var url = _spPageContextInfo.webAbsoluteUrl + "/Pages/" + fileLeafRef;
if (title) {
return "<a href='" + url + "'>" + title + "</a>";
} else {
return "<a href='" + fileRef + "'>" + fileLeafRef + "</a>";
}
}
Can be rewritten to:
function overrideNameFieldTemplate(ctx, CurrentFieldSchema, CurrentItem, ListSchema) {
var url = CurrentItem.FileRef,
title = CurrentItem.Title;
if (title) {
url = _spPageContextInfo.webAbsoluteUrl + "/Pages/" + CurrentItem.FileLeafRef;
} else {
title = CurrentItem.FileLeafRef;
}
return String.format("<a href='{0}'>{1}</a>", url, title);
}