Open Document Directly via Title Column?

When viewing my document library either from its page or within a web part, I would like the default Title column to be a link by default which will open the document (like the Name column).

I've tried adding linkToItem="TRUE" within the FieldRef tag but this opens the document's properties (DispForm.aspx) and not the document itself. Any help is appreciated! Thank you for your time.

EDIT: Updated thread's title from "linkToItem not opening document" to "Open Document Directly via Title Column?" to more accurately represent what I'm asking.

  • Edited by jjnnugent Thursday, May 28, 2015 8:02 PM
May 28th, 2015 12:13am

Hi,

Have you tried the code above ?

If you want to only show the Title(Link To Document) and Created fields, you can hide the other fields in the current list view settings.

The code can also link the title to document directly without the Name field in the view.

Here is a screen capture in my environment like below for your reference:

Thanks

Best R

Free Windows Admin Tool Kit Click here and download it now
May 31st, 2015 11:24pm

Hi,

Have you tried the code above ?

If you only want to show the Title(Link To Document) and Created fields, you can hide the other fields in the current list view settings.

The code can also link the title to document directly without the Name field in the view.

Here is a screen capture in my environment like below for your reference:

Thanks

Best R

June 1st, 2015 3:22am

You can add the link to the title and this link will redirect you to the document...

(function () { var overrideNameField = {}; overrideNameField.Templates = {}; overrideNameField.Templates.Fields = { "Title": { "View": overrideNameFieldTemplate } }; SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideNameField); })(); // This function provides the rendering logic for list view function overrideNameFieldTemplate(ctx) { var title= ctx.CurrentItem["Title"]; var file = ctx.CurrentItem["EncodedAbsUrl"]; if (title) { return "<p><a href='"+ file + "'>"+ title + "</a></p>"; } }

Actualy this thing will help you to view or download document...........

Free Windows Admin Tool Kit Click here and download it now
June 1st, 2015 8:53am

@JerryZy I've tested multiple pages with the code you provided. While it certainly does make the Title field a link, if the Name (linked to document) is disabled in the view, the Title is linked to "undefined" and does not open the document when clicked.

If you're getting different results on your end, how exactly how you implementing the code you provided to the page?

Thanks again.

June 3rd, 2015 7:43pm

@Ravi_Katariya When I implement your code snippet I get the following error:

Free Windows Admin Tool Kit Click here and download it now
June 3rd, 2015 7:49pm

Hi,

In my environment, the Title render the correct document link as the capture below:

I save the code above in a js file and then upload to a document library and in the document library web part JSLink property, I reference the js file path like below:

I suggest you can recreate a new document library and then try to test if the code works as expect.

Thanks

Best R

June 4th, 2015 1:40am

@jjnnugent...

Sorry for late reply...nw I have updated my code....actualy we are fetching url into file variable so in href tag use file variable which will take you to the document...

Hope it will help.......

Thank you...

Free Windows Admin Tool Kit Click here and download it now
June 4th, 2015 12:22pm

@JerryZy I noticed in your snapshots your Type (icon linked to document) view was enabled and that's why we were getting different results.

On your end, does Type (linked to document) or Name (linked to document) have to be enabled for your code to work?

You've helped me so much! Thank you again for your assistance.

June 5th, 2015 12:05am

@Ravi_Katariya

On my end, if Type (linked to document) or Name (linked to document) is enabled your code works. Does your code work on your end if you disable all the "linked to document" columns?

Thanks!

Free Windows Admin Tool Kit Click here and download it now
June 5th, 2015 12:09am

Hi,

I think you need to add the icon or name with link field in the view, otherwise SharePoint will not load the fields in the view. One idea might be, to include the field in the view but then hide the field in JSLink file - not an ideal solution but probably will work. Reference: https://code.msdn.microsoft.com/office/Client-side-rendering-code-2625e5e3

June 8th, 2015 2:52am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics