Hi there,
having read a topic about styling a single table, I found that you can traverse the DOM like shown below; question is though, how can I do this better? I try to set the width of a single table that I create using dataviewjs, to a given width.
Vault Info
Tagged: favorite
var rows=12;
var dateformat = "YYYY-MM-DD hh:mm";
function ftitle(page){
if (typeof page.title !== 'undefined') {
return page.title;
} else {
return page.file.name;
}
}
dv.table(["File","Modified"],
dv.pages('#favorite')
.sort(f=>f.file.mtime.ts,"desc")
.limit(rows)
.map(l=>[
moment(l.file.mtime.toString()).format(dateformat),
"[["+l.file.path+"|"+ftitle(l)+"]]"
]
)
);
console.log(dv)
dv.container.style.width="100%";
dv.container.children[0].children[0].children[0].children[0].children[0].style.width="300px";
Recent file updates
File Count:
$=dv.pages().length
var rows = 12;
var dateformat = "YYYY-MM-DD hh:mm";
function ftitle(page){
if (typeof page.title !== 'undefined') {
return page.title;
} else {
return page.file.name;
}
}
dv.table(["File","Modified"],
dv.pages()
.sort(f=>f.file.mtime.ts,"desc")
.limit(rows)
.map(l=>[
moment(l.file.mtime.toString()).format(dateformat),
"[["+l.file.path+"|"+ftitle(l)+"]]"
]
)
)
dv.container.style.width="100%";
dv.container.children[0].children[0].children[0].children[0].children[0].style.width="300px";