Function filtering DB doesn't work!

Hello!
I have been suffering from this problem few days.
I really want to find the answer to solve this problem!

Quite simple, but I don’t know why…!
What I want to do is shown above picture.

I want to show pictures of product I clicked in form of slideshow gallery.
I have 2 DB, one is DB for repeater containing product information(so called DB-A), and the other is for images of every product(DB-B).

When I link the dataset of gallery to DB-B, it shows first row only. So, I want to filter DB-B when I click ‘show product button’ in repeater for filtering DB with only one row containing information of the product I clicked.

But, When I click show product button, Filter doesn’t work at all. actually, nothing remains in DB-B after my code below works (I tested it with console.log)

Here is my code

import wixData from ‘wix-data’ ;

let imgfilter = wixData.filter();

export function PdButton_click(event) {

let $item = $w.at(event.context);
let PdNumber = $item( ‘#List’ ).getCurrentItem().partNum

imgfilter = imgfilter.hasSome( ‘PdNum’ , PdNumber);
$w( ‘#imgtest’ ).setFilter(imgfilter);

}

and It is my DB

I don’t have any clue at all. Please help me…!

Thank you in advance so much! and have a good day :slight_smile:

import wixData from ‘wix-data’;

let imgfilter = wixData.filter();

export function PdButton_click(event) {
console.log(“Test”) //ADD THIS LINE TO TEST WHETHER THIS FUNCTION IS RUN-ED!
let $item = $w.at(event.context);
let PdNumber = $item(‘#List’).getCurrentItem().partNum

imgfilter = imgfilter.hasSome(‘PdNum’, PdNumber);
$w(‘#imgtest’).setFilter(imgfilter);

}

Why “export function” wont work => https://community.wix.com/partners/forum/technical-talk/members-sign-up-login-corvid-code-not-working

I don’t recognize any difference from my code.
export function works. my problem is that setFilter fuction doesn’t work.

You need to use the Field key (always starts with a small letter) and not the Field name in your query:

You do not want this:

 imgfilter = imgfilter.hasSome('PdNum', PdNumber);

You do want this:

 imgfilter = imgfilter.hasSome('pdNum', PdNumber);

Thank you so much! But I have one more problem :frowning:

It works perfect at the first time.
But, after second run, It gets no data from imgtest DB

I reset the filter for imgtest DB when I close slideshow gallery.
It seems working. but after that, I click other product, It returns null.

This is for slideshow gallery
export function PdButton_click_1(event) {
let $item = $w.at(event.context);
let PdNumber = $item( ‘#List’ ).getCurrentItem().partNum
console.log(PdNumber)

imgfilter = imgfilter.hasSome( 'pdNum' , PdNumber); 
$w( '#imgtest' ).setFilter(imgfilter); 
console.log($w( '#imgtest' ).getCurrentItem()) 
$w( '#closemain' ).show(); 
$w( '#gallery1' ).show(); 
$w( '#PdRepeater' ).hide(); 
$w( '#loadingstrip' ).hide();    

}

and this is for reset filter
export function closemain_click(event) {
$w( ‘#closemain’ ).hide();
$w( ‘#gallery1’ ).hide();
$w( ‘#PdRepeater’ ).show();
$w( ‘#loadingstrip’ ).show();
$w( ‘#imgtest’ ).setFilter(wixData.filter());
}

Thank you so much in advance!

@searchbjd I think that you need to create a new Filter each time. Something like this (not tested):

let imgfilter = wixData.filter().hasSome('pdNum', PdNumber);
$w('#imgtest').setFilter(imgfilter);

@yisrael-wix It is working! Thank you so much! :slight_smile: