How to generate dataviewjs table entries for tasks that link directly to tasks (just like ``tasks``)

Consider the following example:

## Sample data

- [ ] This is line one #test
- [ ] This is line two #test
- [ ] This is line three #test
- [ ] This is line four #test

## Dataview: Task

from #test

## Dataview: Table

const items = dv.pages("#test").file
  ], => [
    "[" + i.text + "](" + i.path + ")",

Which produces the following output:

But I can only get so far as to linking the task to the note.

What I would like to do is to click on the task text and go directly to the task item, exactly like how a dataview tasks query can do it.

What I Have Tried

  • I could link it to the section under a header using dv.sectionLink; but that’s too crude a resolution
  • I could add block-id’s but that’s too much hassle, and, anyway, it appears that dataview does not need that for tasks

So … how does dataview do it’s magic to take me directly to the task without any real reference/anchor?

And how can I replicate that from a dataview javascript query that I can compose in a table?

I’m not sure you actually can do that at all. You can produce a dv.taskList() and get the same functionality, but I’m not sure if you can get that task linking stuff to happen within a table. I’ve not managed to do so reliably so far, at least.

Another option which could be worth looking into, would be to use dv.taskList() but add a visual field to each task. This will replace the original text of the task, but it’ll still be able to link to the original task definition.

Here is an example reversing the task text (just for the fun of it):

##  Task definitions

- [ ] abcdefg
- [ ] vwxyz

## Queried tasks

    .mutate(t => t.visual = t.text.split("").reverse().join("") ),
1 Like

Fantastic! This approach works perfectly :slight_smile: !


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