Want to "call" multiple items from database according to user selection. Can you help?

import wixData from 'wix-data';

var refFields = [], MEMORY = []
//--------- USER-INTERFACE / настройки --------------- User-Interface---------------------

var DATASET     = "#dataset1"
var DATABASE    = "DatosPerfil"
//---------------------------------------
var REFERENCE1  = "actividad" //-> ID of one collection-field (columns in your collection)
var REFERENCE2  = "provincia" //-> ID of one collection-field (columns in your collection)
var REFERENCE3  = "colaborador"//-> ID of one collection-field (column in your collection)
//----- USER-INTERFACE / настройки ------------ User-Interface----------------------------
 
$w.onReady(async function () {
    refFields=[REFERENCE1, REFERENCE2, REFERENCE3]
 //Dropdown_Buttons-----------------------------------------------------------------------
    $w('#DD1, #DD2').onChange(()=>{SEARCH_ENGINE();});
 //Checkbox_Buttons-----------------------------------------------------------------------
    $w('#CB1').onChange(()=>{SEARCH_ENGINE();});
 //Reset_Buttons--------------------------------------------------------------------------
    $w('#btnReset1').onClick(()=>{$w("#DD1").selectedIndex = undefined, SEARCH_ENGINE();})
    $w('#btnReset2').onClick(()=>{$w("#DD2").selectedIndex = undefined, SEARCH_ENGINE();})
 
 
 //Options for CheckBox-1------------------------------
    $w('#CB1').options = [
        {"label": "Embajadores",    "value": "Embajador"},
        {"label": "Embajadas",      "value": "Embajada"},
    ];
 
 //Create-Unique-Dropdown-------------------------------------------------
    wixData.query(DATABASE)
    .limit(1000)
    .find()
    .then(results => {
 const uniqueTitles1 = getUniqueTitles1(results.items);
 const uniqueTitles2 = getUniqueTitles2(results.items);
        $w("#DD1").options = buildOptions1(uniqueTitles1);  //---> ACTIVIDAD
        $w("#DD2").options = buildOptions2(uniqueTitles2);  //---> PROVINCIA
    });
 
 //-------------
 function getUniqueTitles1(items)    {const titlesOnly = items.map(item => item[refFields[0]]); return [...new Set(titlesOnly)];}
 function buildOptions1(uniqueList1) {return uniqueList1.map(curr => {return {label:curr, value:curr};});}
 //-------------
 function getUniqueTitles2(items)    {const titlesOnly = items.map(item => item[refFields[1]]);  return [...new Set(titlesOnly)];}
 function buildOptions2(uniqueList2) {return uniqueList2.map(curr => {return {label:curr, value:curr};});}
 //-------------
})
 
export function BuscarBtn_click(event)  {SEARCH_ENGINE();}
 
function SEARCH_ENGINE() {console.log("Search-Engine started")
 let filter =  wixData.filter()  
 let item1, item2, item3

 //DD1-DD5 = DropDowns------------------------------------------------------
 if ($w('#DD1').value!=="")  {
    item1 = $w('#DD1').value, local.setItem(refFields[0], $w('#DD1').value)
 }
 if ($w('#DD2').value!=="")  {
    item2 = $w('#DD2').value, local.setItem(refFields[1], $w('#DD2').value)
 }
 
 if (item1!==undefined)      {filter = filter.eq(REFERENCE1, item1)}
 if (item2!==undefined)      {filter = filter.eq(REFERENCE2, item2)}

 //DD1-DD5 = DropDowns------------------------------------------------------
 
 //Checkbox-Group-1-----[ Bundesländer ]------------------------------------------------
 if ($w('#CB1').value[0]!==undefined)  {item3 = $w('#CB1').value}
 if (item3!==undefined)  {
 for (var i = 0; i < item3.length; i++) {filter = filter.eq(REFERENCE3, item3[i])}
    }
 else {}

    $w(DATASET).setFilter(filter)
    .then(()=>{
        result_COUNTER()
        $w('#table1').refresh();
    })
}
 
function RESET (parameter) {
    $w("#DD1").selectedIndex = undefined;
    $w("#DD2").selectedIndex = undefined;
    $w('#CB1').value = undefined;
}


//Result-Counter----------------------------------------------
function result_COUNTER() {
 let count = $w(DATASET).getTotalCount().toString();
    console.log("COUNT = " + count)
    $w('#resultCounter').text = count.toString()
} 
 

Ok, you make some progress → you could eleminate your first BUG in your code, by changing to the right DATABASE-ID.
But still one ERROR remaining. What to do?

ERROR—> “local is not defined”

Since i deleted all the code related to the MEMORY-FUNCTION, the → “local”-code-part is not needed anymore…(this should also be the reason for the last Code-Bug).

 //DD1-DD5 = DropDowns------------------------------------------------------
 if ($w('#DD1').value!=="")  {
    item1 = $w('#DD1').value, local.setItem(refFields[0], $w('#DD1').value)
 }
 if ($w('#DD2').value!=="")  {
    item2 = $w('#DD2').value, local.setItem(refFields[1], $w('#DD2').value)
 }

I tried to give your code a better structure and deleted the last unneccessary code-parts… try this code here…

import wixData from 'wix-data';

var refFields = []
//--------- USER-INTERFACE ---------------------
var DATASET     = "#dataset1"
var DATABASE    = "DatosPerfil"
//-------------------------------
var REFERENCE1  = "actividad" 
var REFERENCE2  = "provincia" 
var REFERENCE3  = "colaborador"
//--------- USER-INTERFACE ---------------------
 
$w.onReady(async function () {
    refFields=[REFERENCE1, REFERENCE2, REFERENCE3]
    
    //Options for CheckBox-1--------------------------------------------------------------
    $w('#CB1').options = [
        {"label": "Embajadores",    "value": "Embajador"},
        {"label": "Embajadas",      "value": "Embajada"},
    ];

    //Create-Unique-Dropdown--------------------------------------------------------------
    wixData.query(DATABASE)
    .limit(1000)
    .find()
    .then(results => {
        const uniqueTitles1 = getUniqueTitles1(results.items);
        const uniqueTitles2 = getUniqueTitles2(results.items);
        $w("#DD1").options = buildOptions1(uniqueTitles1);  //---> ACTIVIDAD
        $w("#DD2").options = buildOptions2(uniqueTitles2);  //---> PROVINCIA
    });

    //Dropdown_Buttons--------------------------------------------------------------------
    $w('#DD1, #DD2').onChange(()=>{SEARCH_ENGINE();});
    //Checkbox_Buttons--------------------------------------------------------------------
    $w('#CB1').onChange(()=>{SEARCH_ENGINE();});
    //Search_Buttons----------------------------------------------------------------------
    $w('#BuscarBtn').onClick(()=>{ SEARCH_ENGINE(); });
    //Reset_Buttons-----------------------------------------------------------------------
    $w('#btnReset1').onClick(()=>{$w("#DD1").selectedIndex=undefined, SEARCH_ENGINE();});
    $w('#btnReset2').onClick(()=>{$w("#DD2").selectedIndex=undefined, SEARCH_ENGINE();});
})


//------------- Functions ------------------------------------------------------------
function getUniqueTitles1(items)    {const titlesOnly = items.map(item => item[refFields[0]]); return [...new Set(titlesOnly)];}
function buildOptions1(uniqueList1) {return uniqueList1.map(curr => {return {label:curr, value:curr};});}
//-------------
function getUniqueTitles2(items)    {const titlesOnly = items.map(item => item[refFields[1]]);  return [...new Set(titlesOnly)];}
function buildOptions2(uniqueList2) {return uniqueList2.map(curr => {return {label:curr, value:curr};});}
//-------------
 
function SEARCH_ENGINE() {console.log("Search-Engine started")
  let filter  = wixData.filter()  
  //DropDowns-------------------------------
  let item1   = $w('#DD1').value //---> DropDown
  let item2   = $w('#DD2').value //---> DropDown
  //Checkbox-Group--------------------------
  let item3   = $w('#CB1').value //---> CheckBox 

  //DropDowns-------------------------------
  if (item1!==undefined && item1!=="") {filter = filter.eq(REFERENCE1, item1)}
  if (item2!==undefined && item2!=="") {filter = filter.eq(REFERENCE2, item2)}
  //Checkbox-Group--------------------------
  if (item3!==undefined && item3!=="")  {
      for (var i = 0; i < item3.length; i++) {filter = filter.eq(REFERENCE3, item3[i])}
  }
  $w(DATASET).setFilter(filter)
  .then(()=>{
      result_COUNTER()
      $w('#table1').refresh();
  })
}
 
function RESET (parameter) {
    $w("#DD1").selectedIndex = undefined;
    $w("#DD2").selectedIndex = undefined;
    $w('#CB1').value = undefined;
}

//Result-Counter----------------------------------------------
function result_COUNTER() {
 let count = $w(DATASET).getTotalCount().toString();
    console.log("COUNT = " + count)
    $w('#resultCounter').text = count.toString()
} 

Not tested, but i hope now is everything right. Good luck.:wink:

Good morning!
Thank you @russian-dima !!
Thank you very much for all the effort and for your help.

Sadly… the dropdowns are not working, and the checkbox group only displays the labels but don’t actually filter. I had to remove the search box, and I would need to put it back.

Good thing is that there are no weird code logs ! :slight_smile:

Yeah, for me dropdowns working now Thank you . :wink:

Hi @russian-dima !!
Not sure what happened… but now it works!!! :)))))))))))

Maybe some cache thingy?

I’m finding two issues for which I would really appreciate your assistance:

  • 1 - it should display only “VIP” members- This is a boolean in the collection, and its currently displaying all members.
  • 2 - I need to add a search input field that looks into the description text the member has entered. Like the one you have here:


But I wouldn’t like to mess up all the hard work we have accomplished!!

Could you point me in the right direction to make this filter awesome?
I owe you!!!

Thanks

Glad to hear that it worked :wink:

  1. it should display only “VIP” members
    Let us say you have a datafield with the following ID in your DB —> “vip”.

Add a third dropdown to your page and expand following code-parts…

varREFERENCE4="vip"
refFields=[REFERENCE1,REFERENCE2,REFERENCE3,REFERENCE4]
$w('#DD1, #DD2', #DD3').onChange(()=>{SEARCH_ENGINE();});
const uniqueTitles3 =getUniqueTitles3(results.items);
$w("#DD3").options =buildOptions3(uniqueTitles3);//---> VIP
functiongetUniqueTitles3(items){const titlesOnly = items.map(item=> item[refFields[3]]);return[...newSet(titlesOnly)];}functionbuildOptions3(uniqueList3){return uniqueList3.map(curr=>{return{label:curr, value:curr};});}
let item1, item2, item3, item4
if($w('#DD3').value!==""){item4 = $w('#DD3').value)}
if(item4!==undefined){filter = filter.eq(REFERENCE4, item4)}
functionRESET(parameter){$w("#DD3").selectedIndex=undefined; $w('#CB1').value =undefined;}

This should do it.

  1. I like to help, but sometimes the help gradually mutates into a job.
    What i want to say, now it’S on you how to build the search-function.

I am almost sure, that you can find your answer, when you use the search-function of this forum, or you take a closer look into all the given informations in my interactive example. Surely in one of the given examples, i told about the search-function.

Anyway, which should be your steps to achieve your aim?

  1. creating a search-function, where you will put all the code for your wished function.
  2. of course adding the right elements → input-field+button (giving meaningful IDs).
  3. add a new “onClick” or “onChange”-event (depends on how you want to design it).
  4. adding also a new dropdown, which will hold options (choice in which Datafield you want to do the search).
  5. functions → creating a function which will populate the → “options-dropdown”
    (with this dropdown the user will have the choice in which datafield he wants to do the search).
  6. functions —> creating a search-function which will take the selected choice in the options-dropdown —> “choice-X” → data-field-X.
    and which will take also the value from the input-field —> value-X

you can use for example data-query for this …

wixData.query(DATABASE)
.limit(1000)
.find()
.eq(choice-X,  value-X)
.then(results=>{
	foundItems = results.items
});

Hi @russian-dima
I’m really grateful for the time you are using on helping me!
You cant imagine the hours I’ve spent trying to figure out something and how easy it turns when you share your advice.

It’s amazing what I have learned so far through your messages.

I’ve included the sample you shared. And sadly, now nothing works.

Some info on the database:

  • VIP field is a boolean
  • If VIP is true, then you are able to select:
    • checkbox - tags Embajada, Embajador
    • dropdown - available provincias

I’ve tried setting some filters to the dataset, but nothing happens.

Right before the previous changes, both checkbox and dropdown were working but the “provincias” dropdown displayed all provincias available, not just the vip ones.

Maybe it’s something on the load database I should consider?

2 - I know!
and again, I’m very thankful for your advice!
I’ll be checking all the info you shared step by step to get the search input working.

Thanks again for all your assistance!
I hope you can help me sort this last vip filtering !!! :sweat:

here you can check whats happening…
https://www.elruralnetwork.com/embajadas-y-embajadores

Yes you are right.
When using a booelan-value you have to be tricky! (i did not think about that)

Change the following:

function getUniqueTitles3(items){const titlesOnly = items.map(item=> item[refFields[3]]);return[...newSet(titlesOnly)];}functionbuildOptions3(uniqueList3){return uniqueList3.map(curr=>{return{label:String(curr), value:String(curr)};});}
if(item4!==undefined && item4!==""){
   if(item4==="true") {item4 = true} 
   if(item4==="false") {item4 = false}
   filter = filter.eq(REFERENCE4, item4)
}

This should fix your problem.

You can also dispense to use the function —> getUniqueTitles for the VIP-DropDown and fill the options manually, because you have just 2-options…

$w("#DD8").options = [
    {"label": "true", "value": "true"}, {"label": "false", "value": "false"}
]

I have upgraded my example, take a look one more time on it…
https://www.media-junkie.com/filter-test

As you can see, the dropdown, related to the vip-datafield has also “undifined” as option, because it is filled by the “getUniqueTitles”-function. You have to debug it.
Or you simply use your own manual DropDown-Options for the “vip”-dropdown.

Some more informations, related to this topic…

Get more informations:

Improve your Filter:

https://www.wix.com/velo/forum/coding-with-velo/tags-without-a-repeater

Hi @russian-dima !!!
long time no see! :wink:

I’m sorry it took me too long to get back to you. This got back into my log and just got back to it.

Here’s the catch…

Provincias DD2 - is populated with a form
Actividades - DD1 - too.

Provincias might include 52 items, Actividades… ufff, not sure how many yet… (I’ll end up narrowing this down at some point)

In this members display information page, it should only display those who have certain membership (iniciativas). For this, I have set a boolean that the user has to check (I want to become an Iniciativa).

The dataset had a filter, only displays those true as iniciativa, but it ended up not showing anything (even if they have a membership)

I’ll set the URL as public so you can check what I mean;

https://www.elruralnetwork.com/datos-perfil

The same goes for the counter, it displays all results, never mind if they are “iniciativas” or not.

In this case you suggested, it would match the boolean field and the labels would change to true or false, yet, the labels should stay as available provincias or available actividades, and just show those provincias or actividades that belong to the true field.

$w("#DD8").options =[{"label":"true","value":"true"},{"label":"false","value":"false"}]

Currently,and for testing purposes, there are only 2 iniciativas available.
Once you set the “display all”, it shows… all… not just the Iniciativas.

Do you know a way around this?

Maybe just changing the dataset filters?

I did not really understood your issue completely.
It would be better if you would show your current (related) database and your current code which is related to the problem.

Please delete the DOBLE-POSTING.

Hi!
I’ll try to rephrase :slight_smile:

I have one collection - Datos Perfil
That contains the following fields:
Provincias - text - data is filled from a form
Actividad - text - data is filled from a form
Embajador/embajada - filled as tags manually in the collection.
Pass Co - boolean -filled from a checkbox

On the Iniciativas page:
https://www.elruralnetwork.com/datos-perfil
It should only display those items from the collection that have the boolean true.

The dataset in it currently has a filter for just Passco.
So, once it loads the page, it displays just the passco items.

But… once you hit the dropdown or checkbox:

  • on the dropdown options: it displays all items, not just the passco items of the provincia or actividad fields
  • once you select an option from the dropdown, it displays the item (even if it’s not a passco)
  • the results counter shows all items, not just the pass co ones.

Here’s the collection:

Only “la Prueba” and “El Rural” are Passco. So the dropdown with Provincia, should only display Huelva and A Coruña. but it displays all available items

Same happens with actividad.
If you select a non passco item from the dropdown, it will display in this PassCo section. (An this shouldn’t happen)

On the other hand, the results counter, counts all items, not just the passco ones.

And the dataset only has one filter:

The dataset is called #dataset1

Here’s the code I’m using:

import wixData from 'wix-data';
import wixLocation from 'wix-location';
import wixUsers from 'wix-users';


var refFields = []
//--------- USER-INTERFACE ---------------------
var DATASET     = "#dataset1"
var DATABASE    = "DatosPerfil"
//-------------------------------
var REFERENCE1  = "actividad" 
var REFERENCE2  = "provincia" 
var REFERENCE3  = "colaborador"
var REFERENCE4  = "tipoActividad"
//--------- USER-INTERFACE ---------------------
 
 ///EMAIL BTN
 export function btnemail_click(event) {
    wixLocation.to("mailto:") + $w('#dataset1').getCurrentItem().emailDeContacto.id
}
//Datos de Tags
export function repeater1_itemReady($item, itemData, index){
 let options = [];
 let tags = itemData.tipoActividad;
 let tagLength = tags.length;

    console.log("Item-Data: ", itemData)
    console.log("Index: ", index)
    console.log("Tags: ", tags)

 if(tagLength!==undefined){   
 for(var i=0; i<tagLength; i++){        
            options.push({"label": tags[i],"value": tags[i]})
            $item("#selectionTags1").options = options;
        }
    }
}


$w.onReady(async function () {

 
    refFields=[REFERENCE1, REFERENCE2, REFERENCE3, REFERENCE4]
 
 //Options for CheckBox-1--------------------------------------------------------------
    $w('#CB1').options = [
        {"label": "Embajadores",    "value": "Embajador"},
        {"label": "Embajadas",      "value": "Embajada"},
    ];
    $w('#CB2').options = [
        {"label": "Online",    "value": "Online"},
        {"label": "Presencial",      "value": "Presencial"},
         {"label": "Online y Presencial",      "value": "Online y Presencial"},
    ];

 //Create-Unique-Dropdown--------------------------------------------------------------
    wixData.query(DATABASE)
    .limit(1000)
    .find()
    .then(results => {
 const uniqueTitles1 = getUniqueTitles1(results.items);
 const uniqueTitles2 = getUniqueTitles2(results.items);
        $w("#DD1").options = buildOptions1(uniqueTitles1);  //---> ACTIVIDAD
        $w("#DD2").options = buildOptions2(uniqueTitles2);  //---> PROVINCIA
    });

 //Dropdown_Buttons--------------------------------------------------------------------
    $w('#DD1, #DD2').onChange(()=>{SEARCH_ENGINE();});
 //Checkbox_Buttons--------------------------------------------------------------------
    $w('#CB1').onChange(()=>{SEARCH_ENGINE();});
    $w('#CB2').onChange(()=>{SEARCH_ENGINE();});
 //Search_Buttons----------------------------------------------------------------------
    $w('#BuscarBtn').onClick(()=>{ SEARCH_ENGINE(); });
 //Reset_Buttons-----------------------------------------------------------------------
    $w('#btnReset1').onClick(()=>{$w("#DD1").selectedIndex=undefined, SEARCH_ENGINE();});
    $w('#btnReset2').onClick(()=>{$w("#DD2").selectedIndex=undefined, SEARCH_ENGINE();});
})


//------------- Functions ------------------------------------------------------------
function getUniqueTitles1(items)    {const titlesOnly = items.map(item => item[refFields[0]]); return [...new Set(titlesOnly)];}
function buildOptions1(uniqueList1) {return uniqueList1.map(curr => {return {label:curr, value:curr};});}
//-------------
function getUniqueTitles2(items)    {const titlesOnly = items.map(item => item[refFields[1]]);  return [...new Set(titlesOnly)];}
function buildOptions2(uniqueList2) {return uniqueList2.map(curr => {return {label:curr, value:curr};});}
//-------------
 
function SEARCH_ENGINE() {console.log("Search-Engine started")
 let filter  = wixData.filter()  
 //DropDowns-------------------------------
 let item1   = $w('#DD1').value //---> DropDown
 let item2   = $w('#DD2').value //---> DropDown
 //Checkbox-Group--------------------------
 let item3   = $w('#CB1').value //---> CheckBox 
 let item4   = $w('#CB2').value //---> CheckBox 

 //DropDowns-------------------------------
 if (item1!==undefined && item1!=="") {filter = filter.eq(REFERENCE1, item1)}
 if (item2!==undefined && item2!=="") {filter = filter.eq(REFERENCE2, item2)}
 //Checkbox-Group--------------------------
 if (item3!==undefined && item3!=="")  {
 for (var i = 0; i < item3.length; i++) {filter = filter.eq(REFERENCE3, item3[i])}
 if (item4!==undefined && item4!=="")  {
 for (var i = 0; i < item4.length; i++) {filter = filter.eq(REFERENCE4, item4[i])}
  }

  $w(DATASET).setFilter(filter)
  .then(()=>{
      result_COUNTER()
      $w('#table1').refresh();
  })
}
 
function RESET (parameter) {
    $w("#DD1").selectedIndex = undefined;
    $w("#DD2").selectedIndex = undefined;
    $w('#CB1').value = undefined;
    $w('#CB2').value = undefined;
}

//Result-Counter----------------------------------------------
function result_COUNTER() {
 let count = $w(DATASET).getTotalCount().toString();
    console.log("COUNT = " + count)
    $w('#resultCounter').text = count.toString()
} 

//HIDE ITEMS
$w.onReady(() => {
    $w("#dataset1").onReady(() => {
 // Gets the current item properties and stores them in a variable called item
 const item = $w("#dataset1").getCurrentItem();
 // Checks if the current item has a value in the "video" field
 
 if (!item.imada) {
            $w("#ImEmbajada").hide();
        }
 if (!item.imor) {
            $w("#ImEmbajador").hide();
        }
    });
});
}



Drop me a line to let me know if its clearer now :slight_smile:

Thanks a ton!!!

The dataset in it currently has a filter for just Passco. So, once it loads the page, it displays just the passco items.
This will not work. You are controling the dataset with CODE. Your connected filter from the UI will be overwritten by CODE. If you do not have this filter integrated in your code, it also will NOT work.

I already showed you here…
https://www.media-junkie.com/filter-test
…how to work with TRUE/FALSE (boolean)-filtering .

Go several steps(posts) back and read again, please.

And i also suggested you, that it is not really recommended to use onReady() more then once…

Here your new CODE…(with just one —> onReady( ) & some improvements )

import wixData from 'wix-data';
import wixLocation from 'wix-location';
import wixUsers from 'wix-users';


var refFields = []
//--------- USER-INTERFACE ---------------------
var DATASET     = "#dataset1"
var TABLE       = "#table1"
var REPEATER    = "#repeater1"
var DATABASE    = "DatosPerfil"
//-------------------------------
var REFERENCE1  = "actividad" 
var REFERENCE2  = "provincia" 
var REFERENCE3  = "colaborador"
var REFERENCE4  = "tipoActividad"
//--------- USER-INTERFACE ---------------------
 

$w.onReady(async function () {
    $w(DATASET).onReady(() => {
 // Gets the current item properties and stores them in a variable called item
 const item = $w(DATASET).getCurrentItem();
 // Checks if the current item has a value in the "video" field
 if (!item.imada) {$w("#ImEmbajada").hide();}
 if (!item.imor) {$w("#ImEmbajador").hide();}

        refFields=[REFERENCE1, REFERENCE2, REFERENCE3, REFERENCE4]
 
 //Options for CheckBox-1--------------------------------------------------------------
        $w('#CB1').options = [
            {"label": "Embajadores",    "value": "Embajador"},
            {"label": "Embajadas",      "value": "Embajada"},
        ];
 //Options for CheckBox-2--------------------------------------------------------------
        $w('#CB2').options = [
            {"label": "Online",    "value": "Online"},
            {"label": "Presencial",      "value": "Presencial"},
            {"label": "Online y Presencial",      "value": "Online y Presencial"},
        ];

 //Create-Unique-Dropdown--------------------------------------------------------------
        wixData.query(DATABASE)
        .limit(1000)
        .find()
        .then(results => {
 const uniqueTitles1 = getUniqueTitles1(results.items);
 const uniqueTitles2 = getUniqueTitles2(results.items);
            $w("#DD1").options = buildOptions1(uniqueTitles1);  //---> ACTIVIDAD
            $w("#DD2").options = buildOptions2(uniqueTitles2);  //---> PROVINCIA
        });

 //Dropdown_Buttons--------------------------------------------------------------------
        $w('#DD1, #DD2').onChange(()=>{SEARCH_ENGINE();});
 //Checkbox_Buttons--------------------------------------------------------------------
        $w('#CB1').onChange(()=>{SEARCH_ENGINE();});
        $w('#CB2').onChange(()=>{SEARCH_ENGINE();});
 //Search_Buttons----------------------------------------------------------------------
        $w('#BuscarBtn').onClick(()=>{ SEARCH_ENGINE(); });
 //Reset_Buttons-----------------------------------------------------------------------
        $w('#btnReset1').onClick(()=>{$w("#DD1").selectedIndex=undefined, SEARCH_ENGINE();});
        $w('#btnReset2').onClick(()=>{$w("#DD2").selectedIndex=undefined, SEARCH_ENGINE();});
    });

 //Datos de Tags
    $w(REPEATER).onItemReady(($item, itemData, index) => {
 let options = [];
 let tags = itemData.tipoActividad; console.log("Tags: ", tags)
 let tagLength = tags.length; console.log("Tag-Length: ", tagLength)
        console.log("Item-Data: ", itemData)
        console.log("Index: ", index)
 
 if(tagLength!==undefined){   
 for(var i=0; i<tagLength; i++){        
                options.push({"label": tags[i],"value": tags[i]})
                $item("#selectionTags1").options = options;
            }
        }
    });

 ///EMAIL BTN
    $w('#btnemail').onClick(()=>{
        wixLocation.to("mailto:") + $w(DATASET).getCurrentItem().emailDeContacto.id
    });
});


//------------- Functions ------------------------------------------------------------
function getUniqueTitles1(items)    {const titlesOnly = items.map(item => item[refFields[0]]); return [...new Set(titlesOnly)];}
function buildOptions1(uniqueList1) {return uniqueList1.map(curr => {return {label:curr, value:curr};});}
//-------------
function getUniqueTitles2(items)    {const titlesOnly = items.map(item => item[refFields[1]]);  return [...new Set(titlesOnly)];}
function buildOptions2(uniqueList2) {return uniqueList2.map(curr => {return {label:curr, value:curr};});}
//-------------
 
function SEARCH_ENGINE() {console.log("Search-Engine started")
 let filter  = wixData.filter()  
 //DropDowns-------------------------------
 let item1   = $w('#DD1').value //---> DropDown
 let item2   = $w('#DD2').value //---> DropDown
 //Checkbox-Group--------------------------
 let item3   = $w('#CB1').value //---> CheckBox 
 let item4   = $w('#CB2').value //---> CheckBox 

 //DropDowns-------------------------------
 if (item1) {filter = filter.eq(REFERENCE1, item1)}
 if (item2) {filter = filter.eq(REFERENCE2, item2)}
 
 //Checkbox-Group--------------------------
 if (item3) {for(var i=0; i<item3.length; i++) {filter = filter.eq(REFERENCE3, item3[i])}}
 if (item4) {for (var i=0; i<item4.length; i++) {filter = filter.eq(REFERENCE4, item4[i])}}

    $w(DATASET).setFilter(filter)
    .then(()=>{result_COUNTER()
        $w(TABLE).refresh();
    })
}
 
function RESET () {
    $w("#DD1").selectedIndex = undefined;
    $w("#DD2").selectedIndex = undefined;
    $w('#CB1').value = undefined;
    $w('#CB2').value = undefined;
}

//Result-Counter----------------------------------------------
function result_COUNTER() {
 let count = $w(DATASET).getTotalCount().toString();
    console.log("COUNT = " + count)
    $w('#resultCounter').text = count.toString()
} 

But the implementation of the “PassCo”-Filter you will have to do on your own.
You have all the information inside this thread to solve your problem.

Good luck! :wink:

Hey @russian-dima !
Thank you for the improvement. I had been dealing on how to remove the onready, and didn’t find the way to make it work. I really appreciate this :slight_smile:

I’ve been reading and re reading your previous post, yet I still don’t get it.
I’ve been the whole weekend struggling with different combinations but couldnt make the dropdown just display items that are true on another field.

I’ve already checked https://www.media-junkie.com/filter-test , more than once, and even thou I cant access the code from there, I’ve checked your previous message and can’t see how it could work on this scenario, as it should only display “true” from another column in the dataset.

On this image, there is a dropdown, with options written from code, and filters its own column, the VIP one.
But what if it should display items from another column?

So I’ve been taking a third look at everything…
How do I tackle the PassCo boolean and make the DD Provincias/Actividad (text) filter according to PassCo values (another column field on the collection)?

and how can I “tell” the #DD options only to display the ones that are true, on the other field? And how can I set the counter to match this?

If you have any hint on how to accomplish this I would really appreciate it.

Thanks again!!!

hi @russian-dima
Not sure if you have checked my previous message on this thread.
Sadly the solution you are sharing does not match my current issue.

Thank you anyways for the effort! I really appreciate everything you have shared so far!!!

Sorry, but you ran out of free tips.
https://www.wix.com/velo/forum/coding-with-velo/tags-without-a-repeater

Ok, my last one tip for you!

As i already said…

  1. I like to help, but sometimes the help gradually mutates into a job.

What i want to say, now it’s on you how to …complete your project.

Although, i would say the job is already done.:wink: (and i hope you have learned a lot).