Hi guys. I am building a folder structure view based on “folder” records and child/parent relations. We have a runtime property on the “folder” record, that decides if the subfolders should be shown or not. I have created a recursive JS function to figure out if any parents are closed. My problem is that I need something to trigger a refresh in order to recalculate when the runtime property is changed.
Or am I totally overthinking the problem?
Any feedback is appreciated
Øystein
Hi again guys. Found a solution in the meantime. Here is how I solved it:
I added a runtime property to the datasource, containing a javascript function which recursively iterates through all parent object in search of any that are not expanded. Here is the code for the runtime property:
let returnValue = true;
findParentClosedFolders(CurrentID);
return returnValue;
function isNotNothing(value) {
return value !== undefined && value !== null;
}
function findParentClosedFolders(folderID) {
// Find the folder by ID
const currentFolder = dRFolderAllInTenant.find(folder => folder._id === folderID);
if (currentFolder && isNotNothing(currentFolder.parent)) {
// Find the parent folder
const parentFolder = dRFolderAllInTenant.find(folder => folder._id === currentFolder.parent);
if (parentFolder) {
if (!parentFolder.expanded) {
// The parent exists and is not expanded. Set returnValue to true.
returnValue = false; //true;
} else {
// The parent exists and is expanded. Check its parent recursively.
findParentClosedFolders(parentFolder._id);
}
}
}
}
Great to hear that you found a solution to your problem, but have you checked out the tree / recursive
mode on the Iterating Container
.
It might fit your needs
// Erik
Hi Erik and thank you for your reply. Yes that’s the one I’ve been using
Øystein