Use row ID as identifier to only show a particular repeater container

Hi so i have two repeaters. One is hidden and when opened by a show button, the second repeater opens. I am trying to use an onClick event from the smaller repeater to only open the associated larger repeater container and not all the repeater containers

The collection has a unique ID for each row of data which is associated with each container so is there simple code like onItemReady … getCurrentItem …to link to the onClick event button and only show the one repeater container as a result?


otherwise i’m opening and closing every item in the larger repeater

You can put this in your onClick: a .filter on the dataset for the second repeater, to filter for the id/name/etc. of the clicked item

Thanks Quinten,

what code would i add to do that please

@adcatch02 Is your repeater linked to a dataset?

I have added this code but still opens both containers. I have import Wix Data at the top of the page
export function button46_click(event) {
wixData.get(“myCollection”, “00001”)
.then( (results) => {
let item = results; //see item below
} )
. catch ( (err) => {
let errorMsg = err;
} );

That code will definitely not work :upside_down_face:
Please answer my comment above

@adcatch02 That still will do nothing.

You should, before the .expand function, do this:

let valueSynchronous = ...

$w("#myDataset").setFilter( wixData.filter()
    .eq("Field", valueSynchronous)

Replace Field by an actual field in your second repeater’s database. Replace the … by the thing that fits inside that field, so it can filter.

@webmasterq something like this but just need to add the right …

or maybe could use field key _id

@adcatch02 I am not sure about how you could retrieve the firstName from the clicked item. Maybe somebody more experienced can look at this. You can try to mention a “Corvid Expert”. I can’t help you with this, I’m sorry.

@webmasterq both repeaters are using the same dataset. the small dataset just shows name and the large dataset includes name and an image

@adcatch02 Okay… Wouldn’t it be easier to have an image that’s collapsed, and then expand and change the source when a listing is selected?

@webmasterq The intent is for a large repeater that includes an image and text with a couple of other buttons to dynamic pages to be very visible on the page however if the user doesn’t like the content can hide the large repeater.
The small repeater is collapsed on load.
The small repeater is almost a summary or index of the larger repeater items so is just trying to create choice and functionality for the user

Oh ok

@webmasterq does that help? it would be really good to get this working tonight

I am sorry, I can’t help you with this. I suggest you @mention somebody that can help you, such a as J. D. or givemeawhisky

@webmasterq ok cheers. Thanks for the help you have given me

I think Quinten would be on the right path, you would need to know the value of the person that the button is being clicked from and then set your repeater to be filtered by that person and shown.

Would also go for something unique like the id field too as then you should never have two or more users being shown, whereas if you use first name you can obviously have more than the one, unless you have full name set up or combine first and last name etc.

However, if you are using repeaters, then you would most likely need to code it differently for the repeater. and to get item from the specific repeater container that has the required person in it.

If you look at the Wix API Reference for repeater, then you will see examples already on the page at the Retrieve Repeater Item Data When Clicked section.$w.Repeater.html

Also, check out Yisrael’s great little example which you can open up in your own editor and see how the code works for both actions of inline (inside repeater) or global (outside repeater), which should get you going with this.

Just note that there are two different ways of working with repeaters too, which is stated on the Wix API section for repeaters and you should also notice it when you look at Yisrael’s example and the code for inline and global pages.

When should I use ‘onItemReady’ vs. ‘forEachItem’?

  • To apply data to repeater items with new IDs, you can use the onItemReady() event handler.

  • To update repeater items with existing IDs, you can use the forEachItem() or forItems() functions. forEachItem() updates each repeated item, and forItems() updates only repeated items with the given IDs.

If it was just for one repeater and checking something then it would be so much easier, like in this example!

$w("#dataset1").onReady(() => {
$w("#repeater1").onItemReady(($w, itemData, index) => {

let stock = $w('#dataset1').getCurrentItem().stock;

if (stock > 0) {

} else {
$w('#text16').text = "Sold Out";


Thanks GOS, i’m wondering if this is getting over complicated. I did look at Yisrael’s example but thats not really what i’m trying to achieve.

I have one dataset for two repeaters, a big one (showing a full spectrum of fields) and a micro repeater showing a full name (as a kind of index for the big repeater)

I do not need to add anything to the repeaters but simply use a button on a little repeater item to show the big corresponding repeater as opposed to showing all items if this makes sense

I tried this code but it still opens all items for big repeater and not the like for like item from small to big repeater

$w.onReady( function () {
$w(“#button46”).onClick( (event) => {
let $item = $;
let clickedItemData = $item(“#dataset3”).getCurrentItem();
} );
} );

and i thought a image might help

Little Repeater at the top with two unique items
Big Repeater Item example below

So if i click on one of the little repeater items at the top i only want to open the corresponding big repeater below.

@jonatandor35 Hi J.D.
what are you thoughts on this please?
it feels like it should be a fairly simple code snippet to make this work?