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

Show Attachments with JSLink

$
0
0

Hello,

I have created a custom list view, with JSLink, for announcements list which I use it as FAQ view.

My problem is that I can't show attachments link.

I tried to implement it like in DispForm.aspx but no luck.

Javascript code:

(function () { var accordionContext = {}; accordionContext.Templates = {}; accordionContext.OnPostRender = accordionOnPostRender; accordionContext.Templates.Item = accordionTemplate; SPClientTemplates.TemplateManager.RegisterTemplateOverrides(accordionContext); })(); function accordionTemplate(ctx) { var title = ctx.CurrentItem["Title"]; var description = ctx.CurrentItem["Body"]; var attachments = ctx.CurrentItem["Attachments"]; // Return whole item html return "<tr>" +"<td colspan='13'>" +"<h2 class='heading' style='margin-bottom:0; font-size:16px;color:#2887dc'>" + title + "</h2>" +"<div class='content' style='white-space: -moz-pre-wrap;'>" + description +"<table><tr id='idAttachmentsRow' style='display: table-row;'>"+"<td class='ms-formbody' id='SPFieldAttachments'><table border='0' cellpadding='0' cellspacing='0' id='idAttachmentsTable'><tr><td><span>" + attachments + "</span></td></tr></table></td>" +"</tr></table>" + "</div>" +"</td>" +"</tr>"; } function accordionOnPostRender() {

// if (typeof ShowAttachmentRows == "function") ShowAttachmentRows(); $(".content").hide(); //toggle the componenet with class msg_body $(".heading").click(function () { $(this).next(".content").slideToggle(500); }); $('.heading').css('cursor', 'pointer'); }


Is there any way you can show attachments in custom List View like in DispForm.aspx?

Thanks in advance

Giorgos



Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>