Hello guys,
I am facing another issue with templating of the column for several libraries on the page. There are 5 to 20 libraries and I need to customize always the same column - it is Name column.
The code is working when I use the column manually, choose it and add it in Plumsail Designer.
fd.spRendered(() => {
const value = ctx.row;
const { row, listId, webUrl, rootFolder } = ctx;
const baseUrl = `https://${window.location.host}${
webUrl.length > 1 ? webUrl : ""
}`;
let formUrl = `${baseUrl}/_layouts/15/listform.aspx?PageType=4&ListId=${listId}&ID=${row.ID}`;
if (rootFolder) formUrl += `&RootFolder=${encodeURIComponent(rootFolder)}`;
if (row.ContentTypeId) formUrl += `&ContentTypeID=${row.ContentTypeId}`;
if (!value) {
return "";
}
// Check if the item is a .url file by checking for the _ShortcutUrl property or extension
if (row.FileLeafRef.endsWith(".url") && row._ShortcutUrl) {
// For .url files, make the name clickable and open the link in a new tab
return `
<a href="${row._ShortcutUrl}" target="_blank" data-interception="off" style="text-decoration: none;" onmouseover="this.style.textDecoration='underline';" onmouseout="this.style.textDecoration='none';">
${row.FileLeafRef}
</a>`;
}
// For regular documents (PDFs, Word files, etc.), open the document directly using FileRef
return `
<a href="${row.FileRef}" target="_blank" data-interception="off" style="text-decoration: none;" onmouseover="this.style.textDecoration='underline';" onmouseout="this.style.textDecoration='none';">
${row.FileLeafRef}
</a>`;
});
But I need it this way, programtically:
libraryTitles.map((title) => {
fd.control(title)
.ready()
.then(() => {
console.log(title);
fd.control(title).templates = {
LinkFilename: (ctx) => {
console.log(ctx);
const value = ctx.row;
// console.log(value);
const { row, listId, webUrl, rootFolder } = ctx;
const baseUrl = `https://${window.location.host}${
webUrl.length > 1 ? webUrl : ""
}`;
let formUrl = `${baseUrl}/_layouts/15/listform.aspx?PageType=4&ListId=${listId}&ID=${row.ID}`;
if (rootFolder)
formUrl += `&RootFolder=${encodeURIComponent(rootFolder)}`;
if (row.ContentTypeId)
formUrl += `&ContentTypeID=${row.ContentTypeId}`;
if (!value) {
return "";
}
// Check if the item is a .url file by checking for the _ShortcutUrl property or extension
if (row.FileLeafRef.endsWith(".url") && row._ShortcutUrl) {
// For .url files, make the name clickable and open the link in a new tab
return `
<a href="${row._ShortcutUrl}" target="_blank" data-interception="off" style="text-decoration: none;" onmouseover="this.style.textDecoration='underline';" onmouseout="this.style.textDecoration='none';">
${row.FileLeafRef}
</a>`;
}
// For regular documents (PDFs, Word files, etc.), open the document directly using FileRef
return `
<a href="${row.FileRef}" target="_blank" data-interception="off" style="text-decoration: none;" onmouseover="this.style.textDecoration='underline';" onmouseout="this.style.textDecoration='none';">
${row.FileLeafRef}
</a>`;
},
};
});
});
It looks like it does not execute when I try to console.log something.
Thank you for your help
Stepan