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 }
}) ();
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(&quot;/site/library/view.aspx?ID=" + itemId + "&amp;IsDlg=1&quot;);'>";
    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.

1 Answer 1


We can use the following JavaScript code to achieve it.

<script src="https://code.jquery.com/jquery-1.12.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function() {
        OnPostRender: function(ctx) {                        
                    var fileName=$(this).attr("href").split("/");

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.