Hi,
I am filtering my data with many parameters, after that i would like to show user how many records there are in this search. However, it seems the only way is to build same as filter query at get count from results. Is there any "cleaner" and easy way to get it?
var filter = wixData.filter(); if ($w('#searchInput').value!=='') { filter = filter.contains('nativeEventName', $w('#searchInput').value) .or(filter.contains('tags', $w('#searchInput').value)) ; } if ($w('#dropEventType').value!=='') { filter = filter.eq('eventType', $w('#dropEventType').value); } if ($w('#dropCategory').value!=='') { filter = filter.eq('categoryName', $w('#dropCategory').value); } if ($w('#dropService').value!=='') { filter = filter.eq('serviceName', $w('#dropService').value); } if ($w('#dropdownConnectors').value!=='') { filter = filter.contains('serviceName', $w('#dropdownConnectors').value); } // finally, we set the filter console.log(filter); $w("#datasetEvents").setFilter(filter);
Hi Chana, You really seem to know what you are doing..
I am using a collection called 'voters'. I need to count the number or voters and display it on my home page. As voters register the number needs to automatically update.
wixData.query("Voters") .find() .then((results) => { $w("#dataset2").getTotalCount(); let seq = $w("#dataset2").getTotalCount(); console.log(seq); $w('#input1').type = seq; let allResults = results.totalCount; //console.log(allResults);//this is the number of results //$w('#input1').number = allResults; //$w('#input1').type = allResults; //$w("#input1").type = allResults.toString(); } );
No matter what I try the text field on the page (input1) will not display allREsults. 1. Which field/s should I use for this? 2. What code snippet should I use? 3. Where must the code go, backend data.js file or in the code for the home page?
Thanx for your promp assistance. This is very urgent.
Found simple and elegant solution: instead of duplicate code and build a query, just use
$w("# datasetEvents" ").getTotalCount() in OnChange event of the table.
This will return current number of records in current filter