What I’m trying to do
I’m trying to make the checkboxes clickable in Dataview
I have made a report in DataviewJS to collect all the tasks and filtered them by a tag (#esselunga).
I works and displays me all the tasks with an empty check box.
I would like to have the status displayed too in Dataview and I Would to check a task in the Dataview report and it should check it in the original note too.
I am not confident with Javascript.
Here below is my code:
dataviewjs
// Required to run DataviewJS
const header = "Primo_LUN";
const specificFile = "👤 Magda_prove"; // Replace with your specific file name, without the .md extension
const pages = dv.pages().where(p => p.file.name === specificFile);
// Create a map to group tasks by tags
const tagGroups = {};
// Loop through the specific page and its tasks
for (let page of pages) {
const tasks = page.file.tasks.filter(t => t.section.subpath === header);
tasks.forEach(task => {
const tags = task.text.match(/#[^\s#]+/g) || ['#esselunga'];
tags.forEach(tag => {
if (!tagGroups[tag]) {
tagGroups[tag] = [];
}
tagGroups[tag].push({
text: task.text,
file: page.file.name
});
});
});
}
// Display the tasks grouped by tags
for (const [tag, tasks] of Object.entries(tagGroups)) {
dv.header(3, tag);
// Render tasks as checkboxes using Markdown
dv.paragraph( tasks.map(task =>
`- [${task.completed ? 'x' : ' '}] ${task.text} (from [[${task.file}]])` ).join('\n') );
}
Things I have tried
I tried to ask to ChatGPT, but it gave me some solutions not working in DataviewJS.
Checkboxes clickable.
Anyone can halp me to modify this workin code with checkboxes clickable ?
Thanks in advance.