I’m trying to create a dynamic table with DataviewJS. The table will be used in a concert note - a note that describes one particular concert that I’ve been to. The table will create a row for each artist that I saw at the show (artists are listed in frontmatter).
Here is an example of the metadata used in every concert note:
Index: 13 Artists: - Disturbed - Breaking Benjamin - Alter Bridge - Saint Asonia Date: 2016-07-31 Venue: PNC Bank Arts Center City: Holmdel State: New Jersey Country: United States
And here is the code that I use to create the table. For each artist that I’ve seen, I have a note dedicated to that artist in the ‘Artists’ folder. The code finds the artist note of each artist listed in the concert metadata, and then renders a table for those artists:
let res = new Array(); let page = dv.current(); let artists = dv.array(page.Artists); dv.table( ["File", "Index"], dv.pages('"Concerts/Artists"').where(page => artists.includes(page.Name)) .map(artist => [artist.file.link, artist.Index]))
The code works and does what I want it to do, the issue is the rendering of the table - sometimes it renders properly, but usually it does not. I’ll attach screenshots that show both scenarios:
Example of table not rendering correctly:
Example of table rendering correctly:
Any ideas as to what could be causing this? I’ve never encountered something that works some of the time in Obsidian / Dataview.