$w("help me") .wix(good people who want to help me);

i need to filter the result of another filter from another dataset.
this is the filtering function:
function search() {
let productFilter = wixData.filter();
let categorie = $w(“#categorieBtn”).value;
let instrument = $w(“#instrumentBtn”).value;
let gen = $w(“#genDropdown”).value;
let locatie = $w(“#locatieDropdown”).value;
let luna = $w(“#lunaBtn”).value;
let anul = $w(“#anulBtn”).value;
let ziua = $w(“#ziuaBtn”).value;

        if (gen) { 
            productFilter = productFilter.eq("genMuzical", gen) }  
        if (locatie) { 
            productFilter = productFilter.eq("locatie", locatie); } 
        if (categorie) { 
            productFilter = productFilter.eq("categorie", categorie);} 
        if (instrument) { 
            productFilter = productFilter.eq("instrument", instrument).or(productFilter.eq("instrument2", instrument)); } 
        if (ziua) {productFilter = productFilter.eq("zi2", ziua);} 
        if (luna) {productFilter = productFilter.eq("luna", luna).or(productFilter.eq("luna2", luna));} 
        if (anul) {productFilter = productFilter.eq("liberAn", anul).or(productFilter.eq("an", anul)).or(productFilter.eq("an2", anul));} 
        $w('#dataset1').setFilter(productFilter)    
        .then(() => { 
        let re = $w("#dataset1").getCurrentItem()._owner; 
        wixData.query('querydataset2').eq("_owner", re) 
        let filt = wixData.filter(); 
        filt = filt.eq('_owner', re ); 
           $w('#dataset2').setFilter(filt)   
        });         

}
$w(" #genDropdown , #locatieDropdown , #categorieBtn , #instrumentBtn , #ziuaBtn , #lunaBtn , #anulBtn ").onChange(function () {
search(); });

the problem is that after I filter dataset1, I get only one item … and in that dataset there are several items that match the filters.

please help me … for many days I keep trying to solve the problem … how to get all the items after filtering dataset1 … and after, the filtered items + fieldkey ul (‘’ _owner ") to go through the query dataset2.

i need help …

Already worked with console?

Try this one…
$w(‘#dataset1’).setFilter(productFilter).then((res) => {console.log(res);}

Take look into console, and inspect the output(result).

yes the filters work for dataset 1 ... the problem is how do I go on to take those results and pass them through that query ...the problem is after that line " $w('#dataset1').setFilter(productFilter).then(() => { "  
I need the filtered outputs from dataset 1 to match the query requirement for dataset2

’ let re = $w(“#dataset1”).getCurrentItem()._owner ’ i think the problem is here because, if I have 2 items that match the filters … only one item is shown in the repeater … so I think the problem is at that line … because it takes me one of the 2 items resulting from the filters

@deni_nice69
Show me the opened console-log as screenshot…
$w(‘#dataset1’).setFilter(productFilter).then((res) => { console.log(res) ;}

Ok, you did not understand what i wanted from you :grin:

Look!

  1. You have connected your dataset to a specific DATABASE and surely to a REPEATER or TABLE, too.
  2. You run a filtration…
  3. Your REPEATER or TABLE showing the RESULTS!

Now i wanted you to console-log the results instead of showing me your setup :grin:

However, let me show you a minimalistic example, to demonstrate you how you can get the RESULTS after running a filter…

EXAMPLE-CODE:

import wixData from 'wix-data';

$w.onReady(function () {
    let productFilter = wixData.filter();
        productFilter = productFilter.eq("title", "PRESIDENT") 
        console.log(productFilter) 

    $w('#dataset1').setFilter(productFilter).then((results) =>{
	console.log("Results: ", results)
        console.log($w('#repeater3').data)
    });
});

Here you can see an example-code, which will show you all the MAGIC.

  1. The dataset1 is connected to a REPEATER and to a specific DATABASE in this case to a BADGE-DATABASE, where several BADGES are stored.

  2. Now you generate a FILTER and run that filter, but if you console.log the results, you will recognize that you get no real results after running the filter.

This one → console.log(productFilter) → shows you as RESULT …


So you can’t really use this for further action!

And this console-log → .then((results) =>{console.log("Results: ", results) shows you


So you have got any RESULTS you can continue to work with! Everything until here is useless!

But what about our REPEATER or TABLE which are connected to our DATASET?
Let’s console-log it and see what happens !!! —> console.log($w(‘#repeater3’).data)
And this is the result, which you will get (in this case)…


You now can the the found ITEM and all its filtered DATA ! ! !

Ok! Lets expand the console-functionality and add some more console-logs to inspect a little bit more in DETAIL!!!

let item1 = $w('#repeater3').data[0]
console.log(item1.id)
console.log(item1.title)

So your current code would be…

import wixData from 'wix-data';

$w.onReady(function () {
    let productFilter = wixData.filter();
        productFilter = productFilter.eq("title", "PRESIDENT") 
        console.log(productFilter) 

    $w('#dataset1').setFilter(productFilter).then((results) =>{console.log("Results: ", results)
        console.log($w('#repeater3').data)
        
        let item1 = $w('#repeater3').data[0]
        console.log(item1.id)
        console.log(item1.title)
    });
});

And this would be your RESULTS!

Now do the same technique on your own DATASET and REPEATER or TABLE!
And you will surely find a way of how to continue!

Good-luck!:wink:

Of course you could also use → a normal wix-data-query to get your RESULTS, this would be your alternative way.

@russian-dima after i put this
$w ( ‘#dynamicDataset’ ) . setFilter ( productFilter ) . then (( re ) => {
console . log ( $w ( ‘#repeater1’ ). data ) my result is ok in repeater i obtain the 2 itm from that filter but problem is…how make this 2 result item to filter again to match field key with that query for dataset2

what I want to do is...
- I have a dataset 1, that is connected to repeater 1 and contains user profiles.
- I have a dataset2 with other items 
... what I want to do is ..... 
filter the dataset 2, after getting the filtered items => I want to see in repeater1,  the items from dataset 1 (that match with fieldkey _owner) with the items barely filtered from dataset2 ...

after this line $w(‘#dataset1’).setFilter(productFilter)
.then(() => { … if i use $w(“#dataset1”).getCurrentItem()._owner…my problem is I only get a single item…and after in my query filter…i have that one single item…

You again did not understand my suggention!
You simply can’t do like you do!
Why → current item? That makes no sense!

This is the way you should go…


You have done your first filtration and you got some RESULTS (in your case → 2-items were found).
Open the 3-dots → to inspect the items in DETAIL!
Choose the VALUE you need out of the found item-results to proceed your filtering process in the next step!

Take closer look at my example…

let item1 = $w('#repeater3').data[0]
console.log(item1.id)
console.log(item1.title)