Exclude child nodes from dataviewjs "Tasks" query

Things I have tried

task from "Personal"

What I’m trying to do

I’m trying to list the tasks in a hierarchy or list with their source page name, but I would like to exclude the child nodes inside a task if it has any.

Below is a screenshot representing it:

The following is untested, but what you want is not to include the children, so maybe this would work:

    .map(t => t.children = [] ))`

Sorry for the brevity, as I’m on mobile

Thank you for the code @holroy.

Using filter instead of map worked perfectly

	.filter(t => t.children = [] ))
1 Like

And you’re sure that doesn’t leave out tasks which are supposed to be there? I might have been wrong on the syntax for the map, but using filter I’d reckon it would only pick those tasks not having children/sub-lists from the start…

You are right, its not showing bullets as we go deeper into the childs - like below screenshot:

Found the solution finally.

Along with removing the children, I should also set the parent to “0” or “null”, so that it doesn’t consider that the item is already added from its parents.

	.map(t => {
		t.children = []; 
		t.parent = 0;
		return t;

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.