List tasks without sub-tasks

Things I have tried

Using dataview, I’ve tried to annotate my tasks as follow:

- [ ] [Task:: Main Task Name][Priority:: 3]
     - [ ] Sub-task 1
     - [ ] Sub-task 2

Then I’m listing my “Task” with:

task where Task
sort Priority asc
group by null

is there any way to avoid sub-tasks being shown?

What I’m trying to do

I’m trying to list out all the main tasks (no sub-tasks) sorted by priority

If removing the sub-task is not possible, would it be possible to have them folded onto the main task?

The result should look something like:

Priority 1 - Main Task C - File Name
Priority 3 - Main Task B - File Name
Priority 6 - Main Task A - File Name

Any help appreciated!
Thanks!

About removing sub-tasks, I think that is not possible with simple dataview queries (I don’t know if there’s a way with dataviewjs).
But that is possible if you use a workaround via css, i.e., creating a css snippet to hide subtasks in dataview results.
In the pages where you want to hide subtasks, create a cssclass in yaml frontmatter. For example:

---
cssclass: no-subtasks
---

Then, create a css snippet with this code:

.markdown-preview-view.no-subtasks .dataview.result-group ul.contains-task-list ul {
  display: none;
}

I didn’t try exhaustly this snippet, so I don’t know if there is any conflict with others elements…

3 Likes

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