How to display or note a badge in a repeater ?

Hello,
I create a boolean value in ma database and I would like to know how can I display a badge in repeater when then then boolean is check in the database ?

thanks for your help

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

$w.onReady(function () { 
  wixData("derniereSeance") //its my database nam
  .find()
    .then( (results) => {

 let item = results.items[0];
 let bw_value = item.bw; //bw is my boolean variable in derniereSeance database
 if (bw_value = "true") { //if BW is check in the database the Imagevector 3 is hidden
    vectorImage3.hidden();
  }
} );

Where is your code?
This forum is a code related one!
If you are using the normal Wix-Elements without using any code, then you are wrong here.

You should better contact Wi-Customer-Care… you will find the right link here…
https://russian-dima.wixsite.com/meinewebsite/blank-5

Please do not refer users to Wix Customer Care through an external site.

For questions that are not related to code you can contact Wix Customer Care directly.

I’ve updated my code, with the name of my repeater and vectorImage.
thanks

@yisrael-wix

$w.onReady(function () { 
  wixData("derniereSeance") //its my database nam
  .find()
    .then( (results) => {

 let item = results.items[0];
 let bw_value = item.bw; //bw is my boolean variable in derniereSeance database
 if (bw_value = "true") { //if BW is check in the database the Imagevector 3 is hidden
        $w("#vectorImage3").hide();
  }
} );

Something in like this…

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

$w.onReady(function () { 
    wixData("derniereSeance").find()
    .then( (results) => {
 let item = results.items[0];
 let bw_value = item.bw; 
 
        $w('#repeater1').data = results.items

        $w("#repeater1").onItemReady(($item, itemData, index) => {
 if (bw_value==="true") {$item("#vectorImage3").hide();}
        });
    });
});

@russian-dima

I just read the code and the problem is all the bw value is true. But in the database there true and false value.

The code-snipet i gave you was just an example.
You should always keep your eyes open. Just next to your own post (this one) there is another post, this one …
https://www.wix.com/corvid/forum/community-discussion/get-data-from-dataset-inside-repeater
Where you can find this code-example, which demonstrates another situation.
Check it out, it could be the one you are searching for…

$w.onReady(function () {
  $w("#dataset1").onReady(() => {
    $w("#repeater3").forEachItem(($item, itemData, index) => {
          console.log(itemData)
          console.log(itemData.bw)
    })      
  })
});

Combine the two versions together and create your solution.

You have to change the if-query. So, that it looks for every single data-value in your database. Just run the code shown above and take a look into console.

if (itemData.bw==="true") {$item("#vectorImage3").hide();}

Try one of this two examples…

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

$w.onReady(function () { 
    wixData("derniereSeance").find()
    .then( (results) => {
 let item = results.items[0];
 let bw_value = item.bw; 
 
        $w('#repeater1').data = results.items

        $w("#repeater1").onItemReady(($item, itemData, index) => {
 if (itemData.bw==="true") {$item("#vectorImage3").hide();}
        });
    });
});
$w.onReady(function () {
  $w("#dataset1").onReady(() => {
    $w("#repeater3").forEachItem(($item, itemData, index) => {
         console.log(itemData)
         console.log(itemData.bw)
         if (itemData.bw==="true") {$item("#vectorImage3").hide();}
         else {$item("#vectorImage3").show();}
    })      
  })
});

@russian-dima your code is perfect, thank you very much.

Last question How can I now create a filter to display in my repeater only the true element ?

thanks

@pierrelouis95

As you already said it —> How i can use a FILTER ?!?
The answer is in your question!
Just use a filter!

wixData("derniereSeance").find()
    .eq(REFERENCE, VALUE) //or .contains() .... or .hasSome() ...
    .find()
    .then( (results) => {

And do not forget to leave a like or even a best answer?
Solved in 15min ?

@russian-dima Yes but now I would to hide all the element and not an image. And give the choice to the user with a menu

@pierrelouis95

Look… You will get from the filtering-process some RESULTS right?
You should make a console.log and take a carefully look onto the given results.
Then you will understand what to do.

Here you will get the FILTERED-RESULTS.

wixData("derniereSeance").find()
    .eq(REFERENCE, VALUE) //or .contains() .... or .hasSome() ...
    .find()
    .then( (results) => {

then you make some console.logs…

console.log(results)
console.log(results.items)
console.log(results.items[0].title)
console.log(results.items[0].bw)
console.log(results.items[1].title)
console.log(results.items[1].bw)
console.log(results.items[2].title)
console.log(results.items[2].bw)

In this example you have a for-loop which loops trogh all items.

$w.onReady(function () {
  $w("#dataset1").onReady(() => {
    $w("#repeater3").forEachItem(($item, itemData, index) => {
         console.log(itemData)
         console.log(itemData.bw)
         if (itemData.bw==="true") {$item("#vectorImage3").hide();}
         else {$item("#vectorImage3").show();}
    })      
  })
});

Now it’s on you —> turn on your brain :nerd_face::grin: i am sure you will find the solutoin!
What do you have to change here??? Think about the looping process!

{$item("#vectorImage3").hide();}

Something like… ???

{$item("#myElementID"+index).hide();}

What is that INDEX-THING ??? Did you already analyse it, by using some console.log? ----> console.log(index) ???

You should work more with CONSOLE and RESULTS and take a closer look what happens! Then you will be able to see all the process! And when you will be to see what happens, then you will be to understand what to do in the next step!

I do it here all theoreticaly without seeing your project or code.

Good luck and happy coding!
And do not forget to rate my answer :wink: