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

What I’m trying to do

Simply, I want to display the entire “item”/ piece of data, including children.

So for the majority of my notes, like meeting minutes, I use a lot of indented bullets, but these are all separate “items” and I cant display everything unless I have item.children, item.children.children and so on.

This is probably a very easy fix, I’m just missing something.

- [meeting:: update] || [disseminate:: team] || [date:: 2024-03-15] 
	- line 1 - blah blah blah
		- line 1.1 - blah blah blah
			- line 1.1.1 - blah blah blah
		- line 1.2 - blah blah blah
	- line 2 - whine whine whine
		- line 2.1 - whine whine whine
		- line 2.2 - blah whine blah
```dataview 
table item.text
WHERE disseminate
FLATTEN file.lists as item 
FLATTEN regexreplace(item.text, "\[[^\]]+::[^\]]+\](?:\s*\|\|\s*)?", "") as text 
WHERE item.disseminate
WHERE contains(item.disseminate, "team")
WHERE file.cday >= ( date("2024-03-15") - dur(7days))
SORT file.cday 
```

The item.text should display all the additional lines.

Thanks in advance.

Besides having a disclaimer (or possible 2… :stuck_out_tongue: ) the post below showcases on approach to extending the dataview query language with a function to show the text of all the item.children, which most likely could be adapted to your use case.

And yes, the case displayed there does work in current versions of Obsidian and Dataview.

Haha, that’s a lot of worrying forewarning! But despite the “risky” implementation, it doesn’t quite work for my application.

Inputs

- [example:: hello]
	- there was this
	- then this
		- then that
		- what what
	- generic text
```dataviewjs
const dvF = dv.evaluationContext.functions

// Create a new DQL function
dvF.listChildren =  (ctx, children, offset = "" ) => {
  let result = ""
  for (const child of children) {
    result += offset + "- " +
       (child.task ? `[${ child.status ?? " "}] ` : "" ) +
       child.text + "\n"
    
    if (child.children.length)
      result += dvF.listChildren(ctx, child.children, offset + "  ") 
  }
  return result
}
```
```dataview
  LIST WITHOUT ID item.text + "\n" + listChildren(item.children)
  WHERE file.lists AND example
  LIMIT 5
  FLATTEN file.lists as item
  WHERE !item.parent
```

Output

I only want the list that the inline variable “example” is present in, this seems to display all information in a note containing that variable?

Remember that you need to single out just the list item you want, so try the following:

```dataview
  LIST WITHOUT ID item.text + "\n" + listChildren(item.children)
  WHERE file.lists AND example
  LIMIT 5
  FLATTEN file.lists as item
  WHERE !item.parent` AND item.example
```

Almost there, the “new line” notation and first line is after the variable…

image

It should be:

image

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

You’re the best, thanks @holroy!!!

I don’t want to take the mick, because you have been soo helpful, but I am confident this is an easy one for you:

I dont know if i’ve overcomplicated it, but surely displaying a list of variable keys and values should be really easy…

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