Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

JavaScript JSLink with image disappears when logged in as user with Read Permissions

$
0
0

I'm using the following code to place an icon next to the document name.  Under my Owner account I see the icons.  As a user with Read the icons disappear.

(function () {

    // jQuery library is required in this sample
    // Fallback to loading jQuery from a CDN path if the local is unavailable
    //(window.jQuery || document.write('<script src="//ajax.aspnetcdn.com/ajax/jquery/jquery-1.10.0.min.js"><\/script>'));

    // Create object that have the context information about the field that we want to change it's output render
    var linkFilenameFiledContext = {};
    linkFilenameFiledContext.Templates = {};
    linkFilenameFiledContext.Templates.Fields = {
        // Apply the new rendering for LinkFilename field on list view
        "LinkFilename": { "View": linkFilenameFiledTemplate }
    };

    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(linkFilenameFiledContext);

})();

// This function provides the rendering logic
function linkFilenameFiledTemplate(ctx) {

    //var confidential = ctx.CurrentItem["Confidential"];
    var title = ctx.CurrentItem["FileLeafRef"];

    // This Regex expression use to delete extension (.docx, .pdf ...) form the file name
    title = title.replace(/\.[^/.]+$/, "")

    // Check confidential field value
    if (title) {

        // Render HTML that contains the file name and the confidential icon
        return title + "&nbsp;<img src='/SiteCollectionImages/Read-This-Please-icon-16.png' alt='Mark As Read' title='Mark As Read'/>";

    }
    else {
        return title;
    }

}


David Jenkins


Viewing all articles
Browse latest Browse all 7589

Trending Articles