Dataviewjs: Create callout with result table for each group #2232
-
I'm trying to use dataviewjs to render individual callouts for each key value in a groupby query, and within each callout have it render the respective dv.table. I'm able to do it if I create my own table by creating one big markdown string and using dv.span, but I'd really like to get the actual dataview table in the callout. Here's my code that at least creates the individual callouts and markdown tables:
I started going down the path of trying to use dv.container.createEl but that didn't seem to work at all. Here's what that code looked like:
Any ideas appreciated! EDIT: I've got this almost working using the code below - it renders the callout boxes for each group, but puts all of the tables into the first callout-content div. I'm sure it is something obvious that I'm missing, so any ideas appreciated.
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
OK, solved this tonight. The issue with the tables all being placed in the same callout was because I had to make my
Now if I could just get the results count on the same line as the header text, it would be perfect ... |
Beta Was this translation helpful? Give feedback.
-
I'm not quite sure what's happening in all of your response, but I'm wondering is there any reason you're not using the It kind of seems like you're doing a whole lot of html manipulation, which I don't currently see why you're doing. There could very well be legitimate reasons for them that I just don't see, so sorry if that's the case. |
Beta Was this translation helpful? Give feedback.
OK, solved this tonight.
The issue with the tables all being placed in the same callout was because
let id = (Math.random() + 1).toString(36).substring(14);
was always returning an empty string - the result of(Math.random() + 1).toString(36)
doesn't produce a string long enough forsubstring(14)
to return anything other than an empty string. Changed it tosubstring(7)
and it correctly returned unique values each time.I had to make my
drawCallout
functionasync
so I could await thedv.span
call to create the callout, otherwise the first time through it would calldv.api.table
before the parent callout element had been created. Here's the final working code: