I have been reading up on jslink for sharepoint online, and there are still some things that I am having trouble with.
My goal is to replace all of my calculated columns containing HTML with a jslink file. However, I'm uncertain how to do this a few calc columns, which are fairly complex. The column name is 'DocFolder' and for the sake of clarity, I'll lay out my column as it appears in its calculated column form, explain what they do, and itemize the components used in them. If anyone could either help me or point me in the right direction, it'd be huge.
As an aside, I've read the Microsoft board "intro to js link" as well as the jslink starter pack.
COLUMN NAME DocFolder
- internal/external column names are the same)
- 'Title': OOB SPO column, which holds the name of the item
- openPopUpPeople is a var in the custom script I have embedded on the Site Page
PURPOSE When the icon is clicked, it invokes a modal popup containing all Documents related to an item. This calculated column works in tandem with a custom script I have loaded on a Site Page
QUESTION I. If I'm going to create a JSLink file to replace the calculated column, what changes (if any) are required to be made to the calculated column formula? Do I leave it as is?
QUESTION II. The function works when I use the calculated column in a LVWP with the helper script in a Script Editor on a Site Page. However, when I add this JS Link to the page, the function no longer works. Can someone please help me get this working?
UPDATE FOR BOUNTY, 7/27/17)
I. Here is the calculated column
="<a href="&""""&"javascript:openPopupPeople('"&Title&"')"&""""&">"&"<img src='/SiteAssets/elements/images/folder-open.png' style='height:20px;width:20px;' title='Show all Documents Related to "&Title&"'>"&"</a>"
II. Here is the current JS LINK script for the calculated column, loaded as ~sitecollection/SiteAssets/jslink/jslink_docfolder.js
(function () {
var requestCtx = {};
requestCtx.Templates = {};
requestCtx.Templates.Fields = {
'DocFolder': {'View': linkFieldTemplate}
};
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(requestCtx);
})();
function linkFieldTemplate(ctx) {
var title = ctx.CurrentItem["Title"];
return "<a href='" + javascript:openPopupPeople("Title") + "'><img src='/SiteAssets/elements/images/folder-open.png' style='height:20px;width:20px;'></a>");
}
III. Here is the helper script, which resides on the site page.
<script type="text/javascript">
function openPopupPeople(filterValue) {
var pageUrl =
"https://thejscott.sharepoint.com/SourcesLibrary/Forms/People.aspx?
FilterField1=PeopleId&FilterValue1=" + filterValue;
var options = { url: pageUrl, width: 700, height: 600, title: "JScott People
Docs" };
SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog',
options);
}
</script>