DataviewJS table with Metadata Menu sorted into Groups

What I’m trying to do

Hi everyone! Hope you all are well.

I’m trying to create an editable table with metadata menu where the results are gathered together in groups according to the date the files are scheduled on. It would be similar to the dataview example under Grouped Books linked below, just with dates. Also, I do not want it to show files without dates.

https://blacksmithgu.github.io/obsidian-dataview/api/code-examples/

Things I have tried

I’m using metadata menu and have cobbled together this code. It works for the most part (I don’t think it’s showing notes without dates). However, it isn’t mapping correctly. I say this, because if I replace the portion after async with normal dataview code, the table works, you just can’t edit it. As it is now, however, it outputs a mess (each column on top of one another and no file name).


const { fieldModifier: f } = this.app.plugins.plugins["metadata-menu"].api;

for (let group of dv.pages('"Social Media Activities/YouTube Videos"')
.where(p => p['date']?.toFormat("yyyy-MM-dd") && p['date']!= "")
.groupBy(p => p['date'])) {
    dv.header(3, group.key);
    dv.table(["Name", "Date Scheduled", "Shared"], 
    group.rows
            .map(async p => [
                p.file.link,
                await f(dv, p, "date"),
                await f(dv, p, "shared"),
            ])
        )
}

Does anyone have any thoughts on how I could get this to render properly? I’ve been all over these forums looking for a similar editable table broken out into groups like the one I want to make, but haven’t found anything yet.

Thanks a lot.

Also, in case it matters: One thing that is missing from this code which usually is present in these is this:

await Promise.all(dv.pages(‘“Social Media Activities/YouTube Videos”’)

Usually the codes look something like this:

const { fieldModifier: f } = this.app.plugins.plugins["metadata-menu"].api;
dv.table(["File Name", "Task Type", "Shared"],
  await Promise.all(
    dv.pages('"Social Media Activities/YouTube Videos"')
      .map(async p => [
        p.file.link,
        await f(dv, p, "task_type"),
        await f(dv, p, "shared")
    ])
))

I’m guessing maybe that needs to go back in, but I’m not quite sure how to shove it in there.
But the mapping bit, I don’t know.

Hello!
I also encountered this issue yesterday.
The solution is simple. In a typical example, we put a Dataview request in Promise.all(). And in the example with grouping, we must place the group itself in “Promise”. Promise.all (group.rows e t.c.). So your option should be like this

const { fieldModifier: f } = this.app.plugins.plugins["metadata-menu"].api;

for (let group of dv.pages('"Social Media Activities/YouTube Videos"')
.where(p => p['date']?.toFormat("yyyy-MM-dd") && p['date']!= "")
.groupBy(p => p['date'])) {
    dv.header(3, group.key);
    dv.table(["Name", "Date Scheduled", "Shared"], 
    Promise.all(group.rows
            .map(async p => [
                p.file.link,
                await f(dv, p, "date"),
                await f(dv, p, "shared"),
            ])
        ))
}

Gosh, it still doesn’t format correctly for me :frowning: It comes out with all the dates on the top, and then a long column of check boxes , and no file names. Hmm!!

I appreciate your reply.

Hello!
Here, a version of the note itself with metadata would help in order to understand what data is available and what should be used from this. I myself was just developing a database for YouTube videos. And everything worked out…
I would advise you to ask this question in the dataview channel on Discord. This would help to consider the issue in more detail.