Hi all,
I'd like to customize a document library display form to show the file if it's a jpg.
I can do it in the list view but not in the display form, the ctx.CurrentItem.FileRef and the ctx.CurrentItem.File_x0020_Type are Undefined.
(function() { var overrideCtx = {}; overrideCtx.Templates = {}; overrideCtx.Templates.Fields = { 'Description': { 'DisplayForm': customDisplayField, 'View': overrideFieldTemplate } }; SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx); })(); function customDisplayField(ctx) { return "<img src='" + fileRef + "' style='max-width:200px;'/>"; } function overrideFieldTemplate(ctx) { if (ctx.CurrentItem.File_x0020_Type === "jpg") { return "<img src='" + ctx.CurrentItem.FileRef + "' style='max-width:200px;'/>"; } else { return "<i>no preview available</i>"; } }
Is there a way to retrieve the file path and extension in the display form?
I know that can be a silly question but I'm really new to jsLink, I've started just yesterday.
thankyou
Cinzia
- Edited by CinziaTa Wednesday, August 19, 2015 2:10 PM