In DataviewJS how can I make table cells rendered with dv.table() appear in their own rows?

I have this DataviewJS script with Metadata Menu to show a bunch of tasks and some of their properties, I want to change it so “notes” appears in its own row below the one its from.

const { fieldModifier: f } = this.app.plugins.plugins["metadata-menu"].api;
dv.container.className += ' TaskTable'
const { query, filter } = input

dv.table(
    ["", 
     "􀐫 Due",
     "Size",
     "P #",
     "Status",
     "􀐫 Started",
     "Notes"], 
    await Promise.all(
        dv.pages(query).where(new Function('p', 'return ' + filter))
            .sort(b => -b.AtomicID)
            .map(async d => [
                d.file.link,
                f(dv, d, "Date Due"),
                f(dv, d, "Task Size"),
                f(dv, d, "Priority"),
                f(dv, d, "Status"),
                f(dv, d, "Date Started"),
                f(dv, d, "Notes")
            ])
    ),
);

I solved it using a solution to another post here, I wrote this JS:

const { fieldModifier: f } = this.app.plugins.plugins["metadata-menu"].api;
dv.container.className = dv.container.className.includes('TaskTable') ? dv.container.className : `${dv.container.className} TaskTable`
const { query, filter } = input

const format = (dv, d, field) => {
    function appendElement(newClass) { 
    let oldClass = element.getAttribute("class")
    newClass = `${oldClass?oldClass:""} ${newClass}`
    element.setAttribute("class", newClass)
    }; let element = f(dv, d, field);
    if (field.includes("Date ") && !isNaN(Date.parse(element.textContent)))
        element.textContent = moment(element.textContent).format("YYYY-MM-DD")
    if (field.includes("Date Due") && !isNaN(Date.parse(element.textContent)) && new Date(element.textContent) < new Date()) {
        appendElement("TaskOverdue"); 
    }; if (field === "Priority")
        appendElement(`Priority${element.textContent}`);
    return element;
};

pages = dv.pages(query).where(new Function('p', 'return ' + filter)).sort(page => page.Priority, "desc")
let rows = [];

for (let [i, p] of Object.entries(pages.values)) {
    rows.push([
        p.file.link,
        await format(dv, p, "Date Due"),
        await format(dv, p, "Task Size"),
        await format(dv, p, "Priority"),
        await format(dv, p, "Status"),
        await format(dv, p, "Date Started"),
        await format(dv, p, "Notes")
    ])
    if (p.Notes) {
        rows.push([p.Notes]);
    }
}

dv.table(["", 
"􀐫 Due",
"Size",
"P #",
"Status",
"􀐫 Started",
"Notes"],
rows);

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.