i have this piece of code that populates a repeater and a table inside each element.
So far everything works but I have a table with 2 columns which must be respectively populated by 2 different databases.
To do this I have found a way to get the right field from the databases but I can’t move the second database variable into the array with the information of the first.
I tried to set an external variable, I tried with Object.assign () but nothing, what do I do?
$$w("#repeater1").onItemReady(($item, itemData, index) => {
$item('#txtCategoryTitle').text = itemData.categoryName;
$item('#txtCategoryDescription').text = itemData.categoryDescription;
getTableVideo(itemData._id)
.then((lesson) => {
let rowsData = [];
for (var i = 0; i < lesson.length; i++) {
let complete = '';
getTableCompleted(lesson[i]._id, wixUsers.currentUser.id)
.then((results) => {
complete = results[0]; // this value is 'Yes'
})
rowsData.push({ 'name': lesson[i].videoName, 'completed': complete, '_id': lesson[i]._id });
console.log(rowsData);
}
$item("#tableVideo").rows = rowsData; // insert into the table
if (currentLessonNumber === undefined) {
$w('#btnResume').label = 'Begin course>';
$w('#btnResume').enable();
} else {
$w('#btnResume').enable();
}
$w('#repeater1').show("fade", { "duration": 500, "delay": 0 })
})
});
output of the code:
completed: ""
name: "3"
_id: "c9ac7293-7d9f-4574-80e6-33571a75514c"