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

**URL:** <https://forum.wixstudio.com/t/use-row-id-as-identifier-to-only-show-a-particular-repeater-container/30725>\
**Category:** Ask the community\
**Tags:** question, code\
**Created:** [January 4, 2020, 4:04pm UTC](https://forum.wixstudio.com/t/use-row-id-as-identifier-to-only-show-a-particular-repeater-container/30725 "2020-01-04T16:04:08Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![adcatch02](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/adcatch02/32/12916_2.png) [@adcatch02](https://forum.wixstudio.com/u/adcatch02)\
**Post date:** [January 4, 2020, 4:04pm UTC](https://forum.wixstudio.com/t/use-row-id-as-identifier-to-only-show-a-particular-repeater-container/30725/1 "2020-01-04T16:04:08Z")

</div>

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?

Thanks  
Adam

---

<div class="post-metadata">

**Author:** ![adcatch02](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/adcatch02/32/12916_2.png) [@adcatch02](https://forum.wixstudio.com/u/adcatch02)\
**Post date:** [January 4, 2020, 7:20pm UTC](https://forum.wixstudio.com/t/use-row-id-as-identifier-to-only-show-a-particular-repeater-container/30725/2 "2020-01-04T19:20:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![webmasterq](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/webmasterq/32/11799_2.png) [@webmasterq](https://forum.wixstudio.com/u/webmasterq)\
**Post date:** [January 4, 2020, 7:24pm UTC](https://forum.wixstudio.com/t/use-row-id-as-identifier-to-only-show-a-particular-repeater-container/30725/3 "2020-01-04T19:24:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![adcatch02](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/adcatch02/32/12916_2.png) [@adcatch02](https://forum.wixstudio.com/u/adcatch02)\
**Post date:** [January 4, 2020, 7:28pm UTC](https://forum.wixstudio.com/t/use-row-id-as-identifier-to-only-show-a-particular-repeater-container/30725/4 "2020-01-04T19:28:58Z")

</div>

Thanks Quinten,

what code would i add to do that please

---

<div class="post-metadata">

**Author:** ![webmasterq](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/webmasterq/32/11799_2.png) [@webmasterq](https://forum.wixstudio.com/u/webmasterq)\
**Post date:** [January 4, 2020, 7:33pm UTC](https://forum.wixstudio.com/t/use-row-id-as-identifier-to-only-show-a-particular-repeater-container/30725/5 "2020-01-04T19:33:56Z")

</div>

@adcatch02 Is your repeater linked to a dataset?

---

<div class="post-metadata">

**Author:** ![adcatch02](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/adcatch02/32/12916_2.png) [@adcatch02](https://forum.wixstudio.com/u/adcatch02)\
**Post date:** [January 4, 2020, 7:35pm UTC](https://forum.wixstudio.com/t/use-row-id-as-identifier-to-only-show-a-particular-repeater-container/30725/6 "2020-01-04T19:35:05Z")

</div>

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;  
} );  
$w(‘#container3’).expand();  
}

---

<div class="post-metadata">

**Author:** ![webmasterq](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/webmasterq/32/11799_2.png) [@webmasterq](https://forum.wixstudio.com/u/webmasterq)\
**Post date:** [January 4, 2020, 7:35pm UTC](https://forum.wixstudio.com/t/use-row-id-as-identifier-to-only-show-a-particular-repeater-container/30725/7 "2020-01-04T19:35:52Z")

</div>

That code will definitely not work 🙃  
Please answer my comment above

---

<div class="post-metadata">

**Author:** ![webmasterq](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/webmasterq/32/11799_2.png) [@webmasterq](https://forum.wixstudio.com/u/webmasterq)\
**Post date:** [January 4, 2020, 7:41pm UTC](https://forum.wixstudio.com/t/use-row-id-as-identifier-to-only-show-a-particular-repeater-container/30725/8 "2020-01-04T19:41:40Z")

</div>

@adcatch02 That still will do nothing.

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

```javascript
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.

---

<div class="post-metadata">

**Author:** ![adcatch02](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/adcatch02/32/12916_2.png) [@adcatch02](https://forum.wixstudio.com/u/adcatch02)\
**Post date:** [January 4, 2020, 7:47pm UTC](https://forum.wixstudio.com/t/use-row-id-as-identifier-to-only-show-a-particular-repeater-container/30725/9 "2020-01-04T19:47:00Z")

</div>

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

![](https://us1.discourse-cdn.com/wix/original/3X/b/9/b9b2b49db3cacdda3e97adfe4f4f895a425d99a2.png)  
or maybe could use field key \_id  
Thanks  
Adam

---

<div class="post-metadata">

**Author:** ![webmasterq](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/webmasterq/32/11799_2.png) [@webmasterq](https://forum.wixstudio.com/u/webmasterq)\
**Post date:** [January 4, 2020, 7:49pm UTC](https://forum.wixstudio.com/t/use-row-id-as-identifier-to-only-show-a-particular-repeater-container/30725/10 "2020-01-04T19:49:48Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![adcatch02](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/adcatch02/32/12916_2.png) [@adcatch02](https://forum.wixstudio.com/u/adcatch02)\
**Post date:** [January 4, 2020, 7:50pm UTC](https://forum.wixstudio.com/t/use-row-id-as-identifier-to-only-show-a-particular-repeater-container/30725/11 "2020-01-04T19:50:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![webmasterq](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/webmasterq/32/11799_2.png) [@webmasterq](https://forum.wixstudio.com/u/webmasterq)\
**Post date:** [January 4, 2020, 7:58pm UTC](https://forum.wixstudio.com/t/use-row-id-as-identifier-to-only-show-a-particular-repeater-container/30725/12 "2020-01-04T19:58:41Z")

</div>

@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?

---

<div class="post-metadata">

**Author:** ![adcatch02](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/adcatch02/32/12916_2.png) [@adcatch02](https://forum.wixstudio.com/u/adcatch02)\
**Post date:** [January 4, 2020, 8:03pm UTC](https://forum.wixstudio.com/t/use-row-id-as-identifier-to-only-show-a-particular-repeater-container/30725/13 "2020-01-04T20:03:15Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![webmasterq](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/webmasterq/32/11799_2.png) [@webmasterq](https://forum.wixstudio.com/u/webmasterq)\
**Post date:** [January 4, 2020, 8:23pm UTC](https://forum.wixstudio.com/t/use-row-id-as-identifier-to-only-show-a-particular-repeater-container/30725/14 "2020-01-04T20:23:41Z")

</div>

Oh ok

---

<div class="post-metadata">

**Author:** ![adcatch02](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/adcatch02/32/12916_2.png) [@adcatch02](https://forum.wixstudio.com/u/adcatch02)\
**Post date:** [January 4, 2020, 8:30pm UTC](https://forum.wixstudio.com/t/use-row-id-as-identifier-to-only-show-a-particular-repeater-container/30725/15 "2020-01-04T20:30:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![webmasterq](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/webmasterq/32/11799_2.png) [@webmasterq](https://forum.wixstudio.com/u/webmasterq)\
**Post date:** [January 4, 2020, 8:52pm UTC](https://forum.wixstudio.com/t/use-row-id-as-identifier-to-only-show-a-particular-repeater-container/30725/16 "2020-01-04T20:52:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![adcatch02](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/adcatch02/32/12916_2.png) [@adcatch02](https://forum.wixstudio.com/u/adcatch02)\
**Post date:** [January 4, 2020, 8:59pm UTC](https://forum.wixstudio.com/t/use-row-id-as-identifier-to-only-show-a-particular-repeater-container/30725/17 "2020-01-04T20:59:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![givemeawhisky](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/givemeawhisky/32/5383_2.png) [@givemeawhisky](https://forum.wixstudio.com/u/givemeawhisky)\
**Post date:** [January 5, 2020, 1:09am UTC](https://forum.wixstudio.com/t/use-row-id-as-identifier-to-only-show-a-particular-repeater-container/30725/18 "2020-01-05T01:09:59Z")

</div>

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.  
[https://www.wix.com/corvid/reference/$w.Repeater.html](https://www.wix.com/corvid/reference/$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.  
[https://www.wix.com/corvid/forum/corvid-tips-and-updates/example-input-repeaters](https://www.wix.com/corvid/forum/corvid-tips-and-updates/example-input-repeaters)

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()](https://www.wix.com/code/reference/$w.Repeater.html#onItemReady) event handler.

- To update repeater items with existing IDs, you can use the [forEachItem()](https://www.wix.com/code/reference/$w.Repeater.html#forEachItem) or [forItems()](https://www.wix.com/code/reference/$w.Repeater.html#forItems) functions. [forEachItem()](https://www.wix.com/code/reference/$w.Repeater.html#forEachItem) updates each repeated item, and [forItems()](https://www.wix.com/code/reference/$w.Repeater.html#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!

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

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

if (stock > 0) {
$w('#button1').enable();

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

})
})
})

```

---

<div class="post-metadata">

**Author:** ![adcatch02](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/adcatch02/32/12916_2.png) [@adcatch02](https://forum.wixstudio.com/u/adcatch02)\
**Post date:** [January 5, 2020, 1:38am UTC](https://forum.wixstudio.com/t/use-row-id-as-identifier-to-only-show-a-particular-repeater-container/30725/19 "2020-01-05T01:38:39Z")

</div>

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 = $w.at(event.context);  
let clickedItemData = $item(“#dataset3”).getCurrentItem();  
$w(‘#container3’).expand();  
} );  
} );

and i thought a image might help

 ![](https://us1.discourse-cdn.com/wix/original/3X/f/1/f127d55fc4048fb26ff86eaa543d3f847a8ae0f8.png)

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.

---

<div class="post-metadata">

**Author:** ![adcatch02](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/adcatch02/32/12916_2.png) [@adcatch02](https://forum.wixstudio.com/u/adcatch02)\
**Post date:** [January 5, 2020, 3:44pm UTC](https://forum.wixstudio.com/t/use-row-id-as-identifier-to-only-show-a-particular-repeater-container/30725/20 "2020-01-05T15:44:42Z")

</div>

@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?  
Regards  
Adam

[Next page](https://forum.wixstudio.com/t/use-row-id-as-identifier-to-only-show-a-particular-repeater-container/30725.md?page=2)
