Hi. I’m having an issue where I’m not able to get the number of items that are returned from a collection after filters are applied to it.
I have an onChange function for some filters. When a filter is changed, this function is called. It creates a filter based on what was selected and applies it to the database. This is shown below.
export function filterChange(event){
//filter chaining here to create a filter
$w("#dataset1").setFilter(filter)
}
From what I read online, I tried adding after the last line above
let count = $w("#dataset1").getTotalCount();
However this only gives me the number of entries found for the previous fitler.
I thought this was because my dataset was not ready and thus fetched the count of the collection before the filters was applied.
So I tried to fetch my count in a page-ready / dataset-ready, but it only returns 0, like shown below.
export function filterChange(event){
//filter chaining here to create a filter
$w("#dataset1").setFilter(filter)
$w.onReady( () => {
$w("#dataset1").onReady( () => {
let count = $w("#dataset1").getTotalCount();
console.log(count)
});
});
I’m running out of ideas. Any takers for a possible solution?
Thanks