Way to have a repeater item know about the others?

I’m guessing the answer is “no, there’s no way” but I thought I’d ask in this forum:

Is there a way to use repeater logic so that an item in a repeater knows something about the previous item or the next item?

For example, say we have an array of items (objects) feeding a repeater block where item#X has a property {P:True}, is there a way to set the same property in item#X+1 to have value = False? Or is the only way to achieve that to run a function over the entire array before it feeds the repeater?

Hi @Alex_Klein

I can see the following approach:

  1. if possible you can modify the array by adding its index to each item
  2. if possible you can modify the array by adding the next item to each item, since it’s just a link it won’t affect the performance

then having the specific (current) index you can get any items in the list by index

Does it make sense?

Regards,
Vlad

I think you mean to basically have two items in each “item”, one visible and one not visible, where the visible one takes property/value of the invisible one into account?

Have an index in each item. Every element in the repeater can see the entire data model. If an element known its own index, it can look up the neighboring elements from the data model.

Hm, I think I understand but want to make sure: give all elements an index as a property. A particular element with index X can get info from the element with index X-1 simply by getting property of the object returned by “get element from array at index = X-1”? Sounds like it should work, will try :grinning:

OK, every item now has an index… here’s an additional problem: the item is a reusable component with its own data model (data container is checked). When I create logic for elements in the item, I only see Page Data and the item’s Data Model as options to wire into logic blocks. How to get at the data model for the repeater block (the “parent” block into which I have placed the reusable component)?

If I unselect “data container” for the reusable component (item), would this solve the issue? But then how can I use logic on elements within item where one element affects other elements? Target elements by id?

I solved our problem by using POD container feature for the element(s) in our reusable component that need to talk to the parent’s data model. Awkward but doable/works :grinning:

1 Like