Question:
On wix studio Dataset onReady is not working. I have used it to wait so i can apply a filter and get totalCount and both error on Live, the error lookslike the dataset isnt ready / loaded.
If i add a 5 second delay all is fine.
I have tried to look at the respnse from the onReady / onReadyAsync but get nothing
I have tried moving it out of the $W.onReady as a seperate function and the same works on dev but not live. The only thing currently that stops it is as i say the 5 second delay.
The dataset id companyWatchList is read only
Any Ideas?
$w.onReady(function () {
$w("#companyWatchList").onReady(()=> {
// Apply the filter once the dataset is ready
$w("#companyWatchList").setFilter(baseFilter)
.then(() => {
// After applying the filter, fetch the FRNs list
let totalItems = $w("#companyWatchList").getTotalCount();
console.log(totalItems)
})
.catch((error) => {
console.error("Error applying filter:", error);
});
});
});
$w.onReady(function () {
// Delay the execution by 5 seconds (5000 milliseconds)
setTimeout(() => {
$w(“#companyWatchList”).onReady(() => {
// Apply the filter once the dataset is ready
$w(“#companyWatchList”).setFilter(baseFilter)
.then(() => {
// After applying the filter, fetch the FRNs list
let totalItems = $w(“#companyWatchList”).getTotalCount();
console.log(totalItems); // Log the total item count
})
.catch((error) => {
console.error(“Error applying filter:”, error);
});
});
}, 5000); // Delay time in milliseconds (5000ms = 5 seconds)
});
Additional information:
createConsoleProxy.ts:68 Error applying filter: TypeError: Cannot read properties of undefined (reading ‘total’)
at getTotalCount (datasetApi.js:255:33)
at eval (index.js:79:22)
at eval (index.js:11:19)
at eval (index.js:125:34)
at Object.eval [as getTotalCount] (index.js:11:19)
at eval (qxle8.js:44:63)