@salman-hammed Unfortunately, no change !
Here my codes and I’ve attached a screenshot result below.
import wixData from ‘wix-data’ ;
$w.onReady( function () {
// Update UI
// build dropdown options from the databases
buildDropOptions( “LinePlan” , “minutesTexts” , “dropMinutes” );
buildDropOptions2( “LinePlan” , “data1” , “dropData1” );
// Handle events
// run ‘initFilter’ on dropdown changes
$w( ‘#dropMinutes, #dropData1’ ).onChange(initFilter);
// run ‘initFilter’ on button click
});
async function buildDropOptions(LinePlan, minutesTexts, dropMinutes) {
if (!LinePlan) throw new Error( “Collection Name is required!” );
if (!minutesTexts) throw new Error( “fieldkey is required!” );
if (!dropMinutes) throw new Error( “dropdown id is required!” );
// remove dublicate value in an object
const removeDublicate = items => [… new Set(items.map(item => item[minutesTexts]))];
// conver array into dropdoptions [“foo”] => [{label: “foo”, value:“foo”}]
const buildOptions = _ => _.map(curr =>({ label: curr, value: curr }));
// fetch the data from the database
const res = wixData.query(LinePlan)
.ascending(minutesTexts)
.limit( 1000 )
.find()
const title = removeDublicate(res.items);
let opts = buildOptions(title);
opts.unshift({ “label” : “All” , “value” : “All” })
$w( “#dropMinutes” ).options = opts;
}
async function buildDropOptions2(LinePlan, data1, dropData1) {
if (!LinePlan) throw new Error( “Collection Name is required!” );
if (!data1) throw new Error( “fieldkey is required!” );
if (!dropData1) throw new Error( “dropdown id is required!” );
// remove dublicate value in an object
const removeDublicate = items => [… new Set(items.map(item => item[data1]))];
// conver array into dropdoptions [“foo”] => [{label: “foo”, value:“foo”}]
const buildOptions = _ => _.map(curr =>({ label: curr, value: curr }));
// fetch the data from the database
const res = wixData.query(LinePlan)
.ascending(data1)
.limit( 1000 )
.find()
const title = removeDublicate(res.items);
let opts = buildOptions(title);
opts.unshift({ “label” : “All” , “value” : “All” })
$w( “#dropMinutes” ).options = opts;
}
// filter the dataset based on the input changes
async function initFilter() {
// save the filter in a variable
// we will update thie variable
// based on user inputs
let filter = wixData.filter();
// get all the values from selectors and store it in a const
const dropMinutes = $w( ‘#dropMinutes’ ).value;
const dropData1 = $w( ‘#dropData1’ ).value;
// check if there is a dropdown value and the value is not all
// if it’s true it will update the filter
// run the eq operation and modify the filter variable
if (dropMinutes && dropMinutes!== “all” ) {
filter = filter.eq( “minutesText” , dropMinutes);
}
// check if there is a dropdown value and the value is not all
// if it’s true it will update the filter
// run the eq operation and modify the filter variable
if (dropData1 && dropData1 !== “all” ) {
filter = filter.eq( “data1” , dropData1 );
}
// check if there is a input value and the value is not “Any”
// if it’s true it will update the filter
// run the contains operation and modify the filter variable
// filter the dataset with the filter options builded
// await for the dataset to be filter
// before running the next line
await $w( ‘#dataset1’ ).setFilter(filter);
// after the dataset is filter getting the total records
// and saving it in the ‘ttl’ variable
let ttl = $w( ‘#dataset1’ ).getTotalCount();
console.log(dataset filtered total found : ${ttl}
)
}
Thank you