Hello guys, I’ll need some help with this. I have a table with 2 dropdown filters. Here is my code and it works perfectly fine but instead of ascending order of dropdown items I would like to list them at my own. Is it possible? I would really appreciate your help because that part is necessary for the project I’m working on. Thanks in advance!
import wixData from ‘wix-data’ ;
$w . onReady ( function () {
uniqueDropDown1 ();
});
function uniqueDropDown1 () {
wixData . query ( "Items1" )
. ascending ( "uzrast" )
. limit ( 1000 )
. find ()
. then ( results => {
**const** uniqueTitles = getUniqueTitles ( results.items );
$w ( "#dropdownUzrast" ). options = buildOptions ( uniqueTitles );
});
**function** getUniqueTitles ( items ) {
**const** titlesOnly = items . map ( item => item.uzrast );
**return** [... **new** Set ( titlesOnly )];
}
**function** buildOptions ( uniqueList ) {
**return** uniqueList . map ( curr => {
**return** { label : curr , value : curr };
});
}
}
export function dropdownUzrast_change ( event ) {
uniqueDropDown2 ();
$w ( "#dropdownKategorija" ). enable ();
}
function uniqueDropDown2 () {
wixData . query ( "Items1" )
. contains ( "uzrast" , $w ( "#dropdownUzrast" ). value )
. limit ( 1000 )
. find ()
. then ( results => {
**const** uniqueTitles = getUniqueTitles ( results.items );
$w ( "#dropdownKategorija" ). options = buildOptions ( uniqueTitles );
});
**function** getUniqueTitles ( items ) {
**const** titlesOnly = items . map ( item => item.kategorija );
**return** [... **new** Set ( titlesOnly )];
}
**function** buildOptions ( uniqueList ) {
**return** uniqueList . map ( curr => {
**return** { label : curr , value : curr };
});
}
}
export function ponistiButton_click ( event ) {
$w ( "#dataset2" ). setFilter ( wixData . filter ())
$w ( "#dropdownUzrast" ). value = **undefined** ;
$w ( "#dropdownKategorija" ). value = **undefined** ;
}
P.S. my button for clearing filters works but when I try to apply new filters after reset, it shows me the whole table without applied filters. Any help for that?