I have several SharePoint 2013 document libraries where I want to show the full document name (incl. file extension) instead of the default Name field. I know how to do this in a DVWP or by modifying the view via SharePoint Designer, but unfortunately neither of these options is viable in this case. The information I want is already in the metadata and can be selected by modifying the view and choosing the column "Name (for use in forms)" instead of "Name (linked to document with edit menu)". Doing so breaks the menu functionality attached to the default field, though.
However, I'm already using the JSLink feature to add some buttons via Javascript and was wondering if it's possible to simply override the text without breaking the menu functionality. For example, can I override the text being displayed (ie - the value of the Title field) with my own (ie - the value of field X) without breaking that menu functionality?
I'm able to replace the text with my own hyperlink (see below), but this completely overrides the field... including the menu feature. I want to know if I can replace only the text being displayed, while leaving the rest intact.
Code Snippet: (replaces the title value with my own hyperlink)
(function () {
var overrideCtx = {};
overrideCtx.Templates = {};
overrideCtx.Templates.Fields = {
'LinkTitle': { 'View': renderLinkTitleLink }
};
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);
}) ();
function renderLinkTitleLink(ctx) {
var itemTitle = ctx.CurrentItem["Title"];
var itemId = ctx.CurrentItem["ID"];
var html = "";
html += "<a style='height:16px; vertical-align:top;' href='#' onClick='javascript:window.open("/site/library/view.aspx?ID=" + itemId + "&IsDlg=1");'>";
html += "" + itemTitle + "";
html += "</a>";
return html;
}
I think this gets me most of the way there, but I'm not sure if what I'm trying can be done.