Filter dataset by the text element which is connected to other dataset

I have two datasets in a repeater. I want to filter 2nd dataset by the text element connected to the first dataset. I have used the below code where ‘text92’ and ‘text94’ are the elements connected to the first dataset and ‘dataset 6’ is the 2nd dataset. The below code is not working.


$w.onReady( () => {
    $w("#dataset6").onReady( () => {

 let postername = $w('#text92').text
 let post = $w('#text94').text
 
 const posternamefilter = wixData.filter().contains('posterName', postername)
 const postfilter = wixData.filter().contains('post', post)

$w("#dataset6").setFilter(posternamefilter.and(postfilter))
})
})

Hello Devesh, are you new to the Corvid-Code-Section ?

  1. For INPUTs you should use → Input-Fields and not Text-Fields (that’s the first point).
  2. You want to filter your second dataset by the result of the first filtering-process, right? But you have no first and second process in your code.

You will need something like this one…

import wixData from 'wix-data';

$w.onReady(()=> {
    $w("#dataset6").onReady(()=> {
 
        $w('#button1').onClick(()=> {
        
        let postername = $w('#text92').text
        // let post = $w('#text94').text
 
            $w("#dataset8").setFilter(wixData.filter()
            .contains("posterName", postername)
            )
 
            .then( () => {
 let itemObj =$w("#dataset6").getCurrentItem()
                console.log("Dataset is now filtered")
                console.log(itemObj)
                console.log(itemObj.title)
                console.log(itemObj.name)
                console.log(itemObj._id)
            })
            .catch( (err) => {
            console.log(err)
            })
        })
    })
})

First-Step done! You have found your first value to put it into the second filter-process.

Now you can take this RESULT (founded postername) of this first filtering-process and do the same again in a second filtering process → your second step.

In this example a button-click was used by “button1”.

You can see the results in the CONSOLE.

Hey Russian-Dima,

I’m really new to wix corvid code section

I can’t quite figure out how to make a repeater on one page when a button is clicked filter the database of the repeater on another page

You will first to be able to understand basics, before you do more complicated codings. It will surely take some time till you will get your result. But never give up. Some helping examples on several issues, you can find here…

https://russian-dima.wixsite.com/meinewebsite

You can follow the posts which you can find integrated by a link in each example.
To see new examples and post, you also can folow me here at forum, perhaps this may increase your learning process. :wink: