Question:
I am importing a google sheet into a table using Velo and Google Sheet APIs. Everyting is working as expected, including onRowClick which prints all the row’s data correctly. However, for some reaosn, the table does not display the data. Its just blank rows. It seems like a glitch form research, but I would like to see if anyone has faced a similar issue.
Product:
Wix Studio, Tables and Google Sheets
What are you trying to achieve:
I would like to solve this bug or provide a workaround.
What have you already tried:
Additional information:
import { fetchData } from 'backend/google-sheets.jsw';
import wixWindow from 'wix-window';
import wixUsers from 'wix-users';
$w.onReady(async function () {
const userEmail = await wixUsers.currentUser.getEmail();
$w('#invoicetable').pagination = {
type: "pagination",
rowsPerPage: 10,
}
$w("#invoicetable").dataFetcher = getRows;
async function getRows() {
const data = await fetchData();
const { headers, rows } = data;
const columns = headers.map(header => ({
id: header,
datapath: header,
label: header,
width: 100,
type: "string",
visible: true,
}));
let formattedRows = [];
for (let i = 0; i < rows.length; i++) {
const row = {};
for (let j = 0; j < headers.length; j++) {
row[headers[j]] = rows[i][j]
}
formattedRows.push(row)
}
const filteredRows = formattedRows.filter(row => row.Email === userEmail);
console.log(filteredRows)
console.log(columns)
$w('#invoicetable').columns = columns;
return new Promise((resolve, reject) => {
if (data) {
resolve({
pageRows: filteredRows,
totalRowsCount: filteredRows.length,
});
} else {
reject("Failed to fetch data");
}
});
}
$w("#invoicetable").onRowSelect(event => {
const rowData = event.rowData;
console.log(rowData["Invoice #"]);
wixWindow.openLightbox("PayInvoiceLightbox", {
caseId: rowData["Invoice #"],
company: rowData["Name"],
amount: rowData.amount,
caseName: rowData["Case Name"],
email: userEmail,
});
});
});