Reputation: 1495
I created a document library in SharePoint and when I click on a document in a list view (All Documents), it opens the file. Is there a way to change it to open a Display Form for the selected document instead (javascript, ....)? I know you can click ellipses and elipses angain and then View Properties, but I need the actual document link (under the 'Name' column) to do that. Thank you in advance!
Upvotes: 4
Views: 2859
Reputation: 59358
Since in SharePoint 2013 Client-Side-Rendering
(CSR
) is a default rendering mode, below is demonstrated how to customize LinkFilename
field rendering via CSR.
How to render LinkFilename
field with a link to a Display Form page
(function () {
function renderLinkFilename(renderCtx) {
var item = renderCtx.CurrentItem;
var documentDisplayFormUrl = renderCtx.displayFormUrl + '&ID=' + item.ID; //construct document Display Form Url
return '<a href="' + documentDisplayFormUrl + '">' + item.FileLeafRef + '</a>';
}
function registerRenderer()
{
var ctxView = {};
ctxView.Templates = {};
ctxView.Templates.Fields = {
'LinkFilename' : { 'View': renderLinkFilename }
};
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(ctxView);
}
ExecuteOrDelayUntilScriptLoaded(registerRenderer, 'clienttemplates.js');
})();
Set the JSLink property of a List View Web Part:
Advanced
specify
JavaScript template file location in JS Link propertyUpvotes: 3