Linking a Drop down box with a table

I have a drop down box with a list of values. Based on the dropdown box selection, I would want to filter the contents of my table. The Values in the dropdown matches a list of values in a particular column of the table. The table is connected to a dataset.
I have written the below code, but it does not alter the contents of the table based on dropdown value selection

import wixData from ‘wix-data’;
$w.onReady(function () {
$w(“#dynamicDataset”).onReady( () => {
$w(“#dropdown1”).onChange( () =>
{
wixData.query(‘Rfclients’)
.contains(‘Category’, $w(“#dropdown1”).value)
.find()
.then(res => {
$w(‘#table1’).rows = res.items;
});
});
});

Instead I tried the below code, the table gets refreshed but returns with empty records

import wixData from ‘wix-data’;

export function dropdown1_change(event, $w) {
$w(‘#text40’).text=$w(‘#dropdown1’).value;
$w(“#dynamicDataset”).setFilter(wixData.filter()
.contains(“Category”, $w(“#dropdown1”).value));
}

Hi,

Try your first code, and add a refresh() call for it.

Liran.