Search with in dynamic category

Hi,

I have created a collection for 100 people and categories as A, B and C. I have created dynamic page based on categories A, B and C. If i click A than list of people within category A is published.

Now i am trying to create a code where i can search records with in that category. Have written the below code:
import wixData from ‘wix-data’
$w.onReady( function () {

});

export function iTitle_keyPress(event, $w) {
let SearchValue = $w( “#iTitle” ).value;

if ((SearchValue)) {
$w( “#dynamicDataset” ).setFilter(wixData.filter().contains( ‘title’ , SearchValue))
}};

Problem

  1. but it searches data within entire database and

  2. once search value is removed than it list people of all categories.

please help

Thanks

Hi,
if I understand correctly, the default filter was set through the dataset settings.

What you currently do is overriding the filter using the setFilter function (function sets the new filter for the dataset).

In your key press event you need to both filter with the category (A, B or C) and the value of the input element using code.

If i filter A than i should get all the values in the repeater and search should happen within that page filter. Thanks