Skip to content

Commit

Permalink
linking nodes to table
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico Bakomihalis committed Oct 25, 2024
1 parent b8bc509 commit e2c24b2
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions node-parents-children/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function initGrist() {
},
]
});

grist.onRecord(function (record) {
console.log("record", record);
const mapped = grist.mapColumnNames(record);
Expand All @@ -35,7 +36,7 @@ function renderPage(mapped) {
console.log("node", node);

const nodeElement = document.getElementById("node");
nodeElement.innerText = node;
nodeElement.appendChild(renderNode(node));

const parentsElement = document.getElementById("parents");
const parents = mapped.parents;
Expand Down Expand Up @@ -65,11 +66,20 @@ function addNodesToList(listElement, nodes){
nodes.forEach(node => {
const listItem = document.createElement('li');
console.log("DEBUG", "node being added to list", node)
nodeTextItem = document.createTextNode(node);
nodeTextItem = renderNode(node);
listItem.appendChild(nodeTextItem);
listItem.textContent = node;
// listItem.textContent = node;
listElement.appendChild(listItem);
});
}

function renderNode(node){
nodeElement = document.createElement("span");
nodeElement.innerText = node;
nodeElement.addEventListener("click", function(ev){
grist.setCursor({"Node": node});
});
return nodeElement;
}

document.addEventListener("DOMContentLoaded", initGrist);

0 comments on commit e2c24b2

Please sign in to comment.