What I’m trying to do
Background:
Hello, I’m creating a cardview-like display for my obsidian library with DVJS. My knowledge with JS is limited, so not confident I will be able to describe this well. I’ve gotten this far using others’ posts, but I would like to loop instead of manually mapping each row.
```dataviewjs
let results = dv.pages('"Book Box/Books"').sort(p => p.updated, "desc")
dv.table(
"",
[
dv.array([])
.concat(results
.map(k => ["" + k.file.link.withDisplay("^")].join())
.slice(0,4)),
dv.array([])
.concat(results
.map(k => ["" + k.file.link.withDisplay("^")].join())
.slice(5,9)),
dv.array([])
.concat(results
.map(k => ["" + k.file.link.withDisplay("^")].join())
.slice(10,14)),
dv.array([])
.concat(results
.map(k => ["" + k.file.link.withDisplay("^")].join())
.slice(15,19)),
dv.array([])
.concat(results
.map(k => ["" + k.file.link.withDisplay("^")].join())
.slice(20,24)),
]);
```
Things I have tried
I’ve tried using for loops, and DVJS is providing an error referring to async eval. This is above my understanding… could anyone give me some pointers on setting that up? This is what my for loop looked like… I was hoping to have 4 items sliced for each row and the number of rows be enough to shown all items. The error is bellow.
```dataviewjs
let results = dv.pages('"Book Box/Books"').sort(p => p.updated, "desc");
let min = 0;
let len = results.length;
let text = "";
let max = min + 5;
dv.table(
"",
[
async (; min = len; min++) => {
text += '"dv.array([]).concat(results.map(k => ["" + k.file.link.withDisplay("^")].join()).slice("' + min + "," + max + ")),"
}
]);
```
Evaluation Error: eval@[native code]
@
@
asyncEvalInContext@
@
render@
onload@
@capacitor://localhost/app.js:1:1171666
@
executeJs@
@
dataviewjs@
@
@capacitor://localhost/app.js:1:1227056
@capacitor://localhost/app.js:1:1302676
@capacitor://localhost/app.js:1:1301515
h@capacitor://localhost/app.js:1:1214567
@capacitor://localhost/app.js:1:1214817
@[native code]