June 20, 2017 / Kannan / 0 Comments
When you are vieweing a custom view and don’t see the “Edit” menu also called as “Quick Edit”, make sure that particular view has the “Tabular View” configured. This is one of the reasons why sharepoint list’s quick edit is not available in custom viewes.
Steps to configure “Tabular View” to enable quick edit.
- Goto -> List Settings -> Views -> Click on the view where the “Edit” doesn’t show up
- In the view edit page, expand “Tabular View” if not already expanded
- Check the “Allow individual item checkboxes ” checkbox.
- Click “OK” to save the view settings
Now the quick edit should have been enabled.
Note: This is applicable for modern view available in Office 365, SharePoint 2016 & SharePoint 2013.
May 30, 2017 / Kannan / 0 Comments
Recently I had a requirement where the customer wanted to show the actual attachment’s URL in the list view instead of default Icon. Following JSLink code will help to do that.
(function () {
var linkFiledContext = {};
linkFiledContext.Templates = {};
linkFiledContext.Templates.Fields = {
"Attachments": { "View": OverrideAttachmentFieldRendering }
};
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(linkFiledContext);
})();
function OverrideAttachmentFieldRendering(ctx) {
var itemId = ctx.CurrentItem.ID;
var listName = ctx.ListTitle;
return GetAttachments(listName, itemId);
}
function GetAttachments(listName, itemId) {
var url = _spPageContextInfo.webAbsoluteUrl;
var requestUri = url + "/_api/web/lists/getbytitle('" + listName + "')/items(" + itemId + ")/AttachmentFiles";
var htmlString = "<span style='white-space: nowrap;'>No attachment(s)</span>";
$.ajax({
url: requestUri,
type: "GET",
headers: { "ACCEPT": "application/json;odata=verbose" },
async: false,
success: function (data) {
for (var i = 0; i < data.d.results.length; i++) {
htmlString += "<a style='white-space: nowrap;' href='" + data.d.results[i].ServerRelativeUrl + "'>" + data.d.results[i].FileName + "</a>";
if (i != data.d.results.length - 1) {
htmlString += "<br/>";
}
}
},
error: function (error) {
console.log("An error occured while fetching attachment details. Details: " + JSON.stringify(error))
}
});
return htmlString;
}
Source: https://social.msdn.microsoft.com/Forums/office/en-US/29f7998f-ffc5-4877-b975-a49631b53ba2/show-attachments-with-jslink?forum=sharepointdevelopment