You may have seen some new behavior in SharePoint online where Doc Icon links are not clickable in the document library after migration from SharePoint 2010 to SharePoint Online/SharePoint 2013.
The following code can be added as a CEWP in each document library View wherever you need clickable Doc Icon functionality. This is a generic script and can be added to any SharePoint library without making any changes.
- <script type="text/javascript">
- (function () {
- var replaceCtrl = {};
-
- replaceCtrl.Templates = {};
- replaceCtrl.Templates.Fields = { 'DocIcon': { 'View': CustomIcon } };
- SPClientTemplates.TemplateManager.RegisterTemplateOverrides(replaceCtrl);
- })();
-
- function CustomIcon(ctx) {
- if (ctx.CurrentItem.FSObjType == '1') {
- var ret = "<a href=\"" + ctx.CurrentItem.FileRef + "\">" +
- "<img width='16' height='16' title=\"" + ctx.CurrentItem.FileLeafRef + "\" " +
- "class='ms-draggable' alt=\"" + ctx.CurrentItem.FileLeafRef + "\" " +
- "src=\"/_layouts/15/images/FOLDER.GIF\" border='0' DragId='0'/></a>";
- }
- else {
- var ret = "<a href=\"" + ctx.CurrentItem.FileRef + "\">" +
- "<img width='16' height='16' title=\"" + ctx.CurrentItem.FileLeafRef + "\" " +
- "class='ms-draggable' alt=\"" + ctx.CurrentItem.FileLeafRef + "\" " +
- "src=\"/_layouts/15/images/" + ctx.CurrentItem['HTML_x0020_File_x0020_Type.File_x0020_Type.mapico'] + "\" " +
- "border='0' DragId='0'/></a>";
- }
- return ret;
- }
- </script>