Displaying all item information (file.lists.text) including multiple children

Here is a slightly modified version, not the addition of the if (offset == "") result += ... section at the top, and a change of name to listWithChildren:

```dataviewjs
const dvF = dv.evaluationContext.functions

// Create a new DQL function
dvF.listWithChildren =  (ctx, item, offset = "" ) => {
  let result = ""
  if (offset == "") 
    result += item.text + "\n"
    
  for (const child of item.children) {
    result += offset + "- " +
       (child.task ? `[${ child.status ?? " "}] ` : "" ) +
       child.text + "\n"
    
    if (child.children.length)
      result += dvF.listChildren(ctx, child.children, offset + "  ") 
  }
  return result
}

```

And now the query looks like:

```dataview 
LIST WITHOUT ID listWithChildren(item)
WHERE file.lists AND example
LIMIT 5
FLATTEN file.lists as item
WHERE !item.parent AND item.example
```

And it produced this output:

Hopefully that works as you want it! :smiley:

( Insert the same disclaimers as before… :smiley: )

1 Like