What I’m trying to do
I followed the video by fromSergio to create a small books library in a folder called “Books” and I have a basic table view in regular dataview which lists them and sorts them appropriately.
The frontmatter contain (among other items), the following:
---
tag: 📚Book
title: "The Garderobe of Death"
author: [Howard of Warwick]
series:
name: Chronicles of Brother Hermitage
number: 2
status: reading
read:
start: 2023-03-08
finish:
rating:
---
The basic table sorts appropriately using sort series.name, series.number
but I would like to try to create a subheader for each series under the author. To that end, I’ve started with the example from the dataviewjs website, and modified it to fit my layout. It will group by author appropriately, and I am able to (thus far) get it to sort by the series number, but before I move to trying to also group by the series name, I’d like to just display them in a table field. While the sort works, every time I try to include either the series name or number in the table itself, it throws an error.
Things I have tried
Here is the code that works:
'''dataviewjs (backticks changed for forum post)
for (let group of dv.pages('"Books"').groupBy(p => p.author)) {
dv.header(3, group.key);
dv.table(["Name", "Series", "Num", "Rating"],
group.rows
.sort(k => k.series.number)
.map(k => [k.file.link, k.series, k.series, k.rating])) }
'''
That yields a table grouped by author, ordered by series.number, and with name: Chronicles of Brother Hermitage number: 1
in each of the fields containing k.series. However while sorting by k.series.number works, if I include k.series.name or k.series.number in the actual map call, it throws an error saying it cannot read name
or number
.
Adding this loop right after the initial for
loop yields what I think should be correct in the debug console:
for (let row of group.rows) {
console.log(row.series);
}
Any idea how I can access those two values in the actual table output?