DataviewJS Snippet Showcase

Hello Luis,

sorry for my super late answer. Forgot to turn on the forum notifications…

in case you still need help here, I put together this dataviewjs code that at least worked with my dummy data:

```dataviewjs
const flattened = [];
dv.pages()
	.where(b => b.term)
	.map(p => {
		p.term = dv.array(p.term)
		p.definition = dv.array(p.definition)
	
		for (let i = 0; i < p.term.length; i++) {
			flattened.push({term: p.term[i], definition: p.definition[i]})
		}
	});
	
dv.table(['Term','definition'], flattened
		 .sort(a => a.term,'asc')
		 .map(a => [a.term,a.definition]))
```

This code takes all terms and definitions and put them into a flattened map, which you then use to render the table. Mind that this means two things: (a) you lose all other information from the page and cannot “just” append more info to the table without also touching the map function. (b) This only works if you always have the same amount of “terms” and “definition” keys.

8 Likes