Filtering repeater separately

Hello.
I am working on a website for the sale of real estate. I need to sort real estate by several parameters. At the moment, I am filtering properties by number of rooms, district and property value. Right now the code only works if you select options in all the dropdowns. That is, if I select only the required number of rooms and press the filter button, the console will give an error:
Error: Failed to perform query on [Apartments].
WDE0058: $ gte should be a Date, Number, or String. Got null instead
WDE0058: $ lt should be a Date, Number, or String. Got null instead

I would like to know if it is possible to filter the data individually.

Code:
import wixData from ‘wix-data’ ;

export function button2_click(event, $w) {
$w( “#dataset1” ).setFilter(wixData.filter()
.eq( “1” , Number($w( ‘#dropdown1’ ).value))
.contains( “district” , String($w( ‘#dropdown2’ ).value))

    .between( "testprice" ,parseFloat($w( '#dropdown3' ).value), parseFloat($w( '#dropdown4' ).value))) 

.then((results) => { 
        console.log( "Dataset is now filtered" ); 
        $w( "#repeater1" ).data = results.items; 
    }). **catch** ((err) => { 
        console.log(err); 
     }); 
$w( "#repeater1" ).expand(); 

}

ты ищешь… ??? (searching for ???)…

https://russian-dima.wixsite.com/wixworld/nedvizhimost

https://russian-dima.wixsite.com/wixworld/nedvizhimost-iiii

https://www.media-junkie.com/pflegeservice —> DB-Preset-2

And YES! It is possible as like you want it to be.

EDIT: Боже мой, нашел свой старый CODE :sweat_smile: (found my very beginning CODE for a filter)
It looks like this, when you start with coding :sweat_smile::rofl:, what a crazy code.

import wixData from 'wix-data';

$w.onReady(function () {
 //TODO: write your page related code here...
});

export function DD1_change(event) {SEARCH_ENGINE()}
export function DD2_change(event) {SEARCH_ENGINE()}
export function DD3_change(event) {SEARCH_ENGINE()}
export function DD4_change(event) {SEARCH_ENGINE()}
export function DD5_change(event) {SEARCH_ENGINE()}
export function input1_change(event) {SEARCH_ENGINE()}
export function input2_change(event) {SEARCH_ENGINE()}
export function BTNtest_click(event) {SEARCH_ENGINE()}

function SEARCH_ENGINE() {console.log("Serchengine started!")
 var input1 = $w("#input1").value
 var input2 = $w("#input2").value
 var item1, item2, item3, item4, item5
 var column1, column2, column3, column4, column5
 var CODE = ""
    console.log(input1)
    console.log(input2)
 
 if ($w('#DD1').value!=0){column1 = "item1",    item1 = $w('#DD1').value,     CODE=CODE + "1"} else{CODE=CODE + "0"}
 if ($w('#DD2').value!=0){column2 = "item2",    item2 = $w('#DD2').value,     CODE=CODE + "1"} else{CODE=CODE + "0"}
 if ($w('#DD3').value!=0){column3 = "item3",    item3 = $w('#DD3').value,     CODE=CODE + "1"} else{CODE=CODE + "0"}
 if ($w('#DD4').value!=0){column4 = "item4",    item4 = $w('#DD4').value,     CODE=CODE + "1"} else{CODE=CODE + "0"}
 
 //special-item-search (item5)
 if ($w('#input1').value!=0 || $w('#input2').value!=0){column5 = "item5",    item5 = $w('#DD5').value,     CODE=CODE + "1"} else{CODE=CODE + "0"}

 //ABFRAGE----------------------------------------------CODE-ZERO
    console.log(CODE)

 if (CODE=="00000"){$w("#dataset1").setFilter(wixData.filter())}

 //ABFRAGE----------------------------------------------Einzeln
 if (CODE=="10000"){$w("#dataset1").setFilter(wixData.filter().eq(column1, item1));}
 if (CODE=="01000"){$w("#dataset1").setFilter(wixData.filter().eq(column2, item2));}
 if (CODE=="00100"){$w("#dataset1").setFilter(wixData.filter().eq(column3, item3));}
 if (CODE=="00010"){$w("#dataset1").setFilter(wixData.filter().eq(column4, item4));}
 if (CODE=="00001"){$w("#dataset1").setFilter(wixData.filter().between(column5, input1, input2));}
 //ABFRAGE----------------------------------------------Duo
 if (CODE=="11000"){$w("#dataset1").setFilter(wixData.filter().eq(column1, item1).eq(column2, item2));}
 if (CODE=="01100"){$w("#dataset1").setFilter(wixData.filter().eq(column2, item2).eq(column3, item3));}
 if (CODE=="00110"){$w("#dataset1").setFilter(wixData.filter().eq(column3, item3).eq(column4, item4));}
 if (CODE=="00011"){$w("#dataset1").setFilter(wixData.filter().eq(column4, item4).between(column5, input1, input2));}
 if (CODE=="10100"){$w("#dataset1").setFilter(wixData.filter().eq(column1, item1).eq(column3, item3));}
 if (CODE=="10010"){$w("#dataset1").setFilter(wixData.filter().eq(column1, item1).eq(column4, item4));}
 if (CODE=="10001"){$w("#dataset1").setFilter(wixData.filter().eq(column1, item1).between(column5, input1, input2));}
 if (CODE=="01001"){$w("#dataset1").setFilter(wixData.filter().eq(column2, item2).between(column5, input1, input2));}
 if (CODE=="00101"){$w("#dataset1").setFilter(wixData.filter().eq(column3, item3).between(column5, input1, input2));}
 if (CODE=="01010"){$w("#dataset1").setFilter(wixData.filter().eq(column2, item2).eq(column4, item4));}
 //ABFRAGE----------------------------------------------Trio
 if (CODE=="11100"){$w("#dataset1").setFilter(wixData.filter().eq(column1, item1).eq(column2, item2).eq(column3, item3));}
 if (CODE=="11010"){$w("#dataset1").setFilter(wixData.filter().eq(column1, item1).eq(column2, item2).eq(column4, item4));}
 if (CODE=="11001"){$w("#dataset1").setFilter(wixData.filter().eq(column1, item1).eq(column2, item2).between(column5, input1, input2));}
 if (CODE=="10101"){$w("#dataset1").setFilter(wixData.filter().eq(column1, item1).eq(column3, item3).between(column5, input1, input2));}
 if (CODE=="10011"){$w("#dataset1").setFilter(wixData.filter().eq(column1, item1).eq(column4, item4).between(column5, input1, input2));}
 if (CODE=="01011"){$w("#dataset1").setFilter(wixData.filter().eq(column2, item2).eq(column4, item4).between(column5, input1, input2));}
 if (CODE=="00111"){$w("#dataset1").setFilter(wixData.filter().eq(column3, item3).eq(column4, item4).between(column5, input1, input2));}
 if (CODE=="10110"){$w("#dataset1").setFilter(wixData.filter().eq(column1, item1).eq(column3, item3).eq(column4, item4));}
 if (CODE=="01110"){$w("#dataset1").setFilter(wixData.filter().eq(column2, item2).eq(column3, item3).eq(column4, item4));}
 //ABFRAGE----------------------------------------------Quadro
 if (CODE=="11110"){$w("#dataset1").setFilter(wixData.filter().eq(column1, item1).eq(column2, item2).eq(column3, item3).eq(column4, item4));}
 if (CODE=="11101"){$w("#dataset1").setFilter(wixData.filter().eq(column1, item1).eq(column2, item2).eq(column3, item3).between(column5, input1, input2));}
 if (CODE=="11011"){$w("#dataset1").setFilter(wixData.filter().eq(column1, item1).eq(column2, item2).eq(column4, item4).between(column5, input1, input2));}
 if (CODE=="10111"){$w("#dataset1").setFilter(wixData.filter().eq(column1, item1).eq(column3, item3).eq(column4, item4).between(column5, input1, input2));}
 if (CODE=="01111"){$w("#dataset1").setFilter(wixData.filter().eq(column2, item2).eq(column3, item3).eq(column4, item4).between(column5, input1, input2));}
 //ABFRAGE----------------------------------------------X5
 if (CODE=="11111"){$w("#dataset1").setFilter(wixData.filter().eq(column1, item1).eq(column2, item2).eq(column3, item3).eq(column4, item4).eq(column5, item5));
        }
    console.log($w('#DD1').value)
    console.log($w('#DD2').value)
    console.log($w('#DD3').value)
    console.log(CODE)
}

But here you should find a much better method how to code a filter…

Thank. I will definitely try.
One more question. Is it possible to set up price filtering based on the entered data? That is, so that the user can enter the amount himself and filter it.

You can do it the same way like it is already show in this example…

…where you can search between 2 values.
https://www.wix.com/velo/reference/wix-data/wixdatafilter/between

Hello.
Unfortunately, on that site I did not find a sample code that is responsible for these parameters.
Could you tell me in more detail?
I am not good at programming, and have been trying to figure out the filter for over a month now.

Thank you in advance.

I’m looking for exactly this! Help me Please @russian-dima !!

@ramazanbugdayci02
You are looking for a —> “between-filtering”, rigt? Yes, right! :grin:

Take a look here at this example…
https://www.media-junkie.com/between-filter-example

How does it work ?

Choose a Database you want from the shown DATABASE-POOL here…
https://www.media-junkie.com/databases
Let us take the —> " Real-Estate "-Database, because it fits the needs of your issue.
Take one of the datafields you want to investigate, for example the " Purchase-Price ".
Pay attention, that the ID can differ from the DATAFIELD-NAME!!!

  1. DATABASE —> " Real-Estate "
  2. DATAFIELD —> " purchaceprice "
  3. Type in —> Value-A & Value-B to do the search between this two values in DB.
  4. Press —> Search-Button
  5. Take a look onto —> RESULT in the TABLE below!
    6 )Have FUN ! :grin:
  6. Like my post and choose BEST-ANSWER :rofl:


Working-CODE:

import wixData from 'wix-data';

$w.onReady(async()=>{
  $w('#button1').onClick(()=>{
    wixData.query($w('#input1').value)
   .between($w('#input2').value, $w('#input3').value, $w('#input4').value) 
   .find()
   .then( (results) => {
     if(results.items.length > 0) {
     let items = results.items; console.log(items)
        $w('#table1').rows = items
        load_TableOptions();
     } 
     else { }
     })
   .catch( (error) => {console.log(error)});
    });
});

async function load_TableOptions() {console.log("LOAD_Table-Options") 
 let cols = []
  $w('#table1').columns = cols;

  cols.push({
 "id": "Col0",
 "dataPath": $w('#input2').value,
 "label": $w('#input2').value,
 "width": 75,
 "visible": true,
 "type": "string"
 });
 
  $w('#table1').columns = cols;
}

But I’ve got repeater. Is it this changing enough?

  $w.onReady(async()=>{
  $w('#button14').onClick(()=>{
    wixData.query("TumIlanlar")
 .between("fiyat", Number($w('#input1').value), Number($w('#input2').value)) 
 .find()
 .then( (results) => {
 if(results.items.length > 0) {
 let items = results.items; console.log(items)
        $w('#propertyList').data = items
 
 } 
 else { }
 })
 .catch( (error) => {console.log(error)});
 });
});


This is the important part for you and the repeater-function…

$w('#propertyList').data = items