Exclude child nodes from a dataview “Tasks” query

I am creating a new post because the old one was closed Exclude child nodes from dataviewjs "Tasks" query and I have a custom css solution to suggest

What I’m trying to do

I am trying to obtain the same result as the linked post attached image but only with CSS

Things I have tried

My solution is very simple :

.mo-journal-content .cm-contentContainer > div > .HyperMD-task-line.HyperMD-list-line-1:not(.HyperMD-quote) {
  box-shadow: 2pt 2pt 2pt ;
  border: 1px solid var(--text-accent);
  font-weight: 800;
}


.dataview.dataview-container > ul > li > span {
  box-shadow: 2pt 2pt 2pt ;
  border: 1px solid var(--text-accent);
  font-weight: 800;
  padding: 0.2em;
}

.dataview.dataview-container ul li ul {
    display: none;
}

My task dataview query

```dataview
TASK
WHERE (!completed or !fullyCompleted)
	AND !parent
	AND scheduled < date(sow)+dur(7 days) and start < date(sow)+dur(7 days)
```
1 Like

That’s a neat little trick, but be aware of two things. Firstly it’ll hide any subitems from any dataview query, if I’m not mistaken. Secondly, this solution doesn’t avoid generating the subitems, it just hides them.

To tackle the first one, you might want to add a cssclasses properties to the css rule set, and to the notes where you want this behaviour. Then only notes with that class property would hide the subitems.

To address the other issue, you might need to go down the other alternatives, or just live with the fact that some extra data is generated and in most cases hidden.

Yes, for my use case is right because I have a personal workflow doesn’t collide with that choice, but is wise to add cssclasses, maybe it should prepend .mo-journal-content also

I know items are hidden but they are still present in the result, but the query result length is acceptable

Thanks