# Perspective FlexRepeater question

**URL:** <https://forum.inductiveautomation.com/t/perspective-flexrepeater-question/78301>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [August 23, 2023, 6:15pm UTC](https://forum.inductiveautomation.com/t/perspective-flexrepeater-question/78301 "2023-08-23T18:15:38Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Babla\_Bogam](https://avatars.discourse-cdn.com/v4/letter/b/ecb155/32.png) [@Babla\_Bogam](https://forum.inductiveautomation.com/u/Babla_Bogam)\
**Post date:** [August 23, 2023, 6:15pm UTC](https://forum.inductiveautomation.com/t/perspective-flexrepeater-question/78301/1 "2023-08-23T18:15:38Z")

</div>

I have a flexrepeater and the instance is a view with a just 1 button. I have an array of strings called "issues". The instances for the flexrepeater are created dynamically in script using the "issues" array. Each instance has 2 properties - issue, index. The button text is bound to issue. What I am trying to do is apply class to the clicked button (thick border on the button to show the user the current active button) by binding to the classes property of style of the button. When the user clicks on lets say button 5 I am able to get the index of that button but how do let other buttons know that the current button is 5? I tried message handler between the button and the parent (flexrepeater) and the flexrepeater knows which button was clicked but I am not able to let other buttons know.

---

<div class="post-metadata">

**Author:** ![Ryan\_Allen](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan_allen/32/47013_2.png) [@Ryan\_Allen](https://forum.inductiveautomation.com/u/Ryan_Allen)\
**Post date:** [August 23, 2023, 6:25pm UTC](https://forum.inductiveautomation.com/t/perspective-flexrepeater-question/78301/2 "2023-08-23T18:25:38Z")

</div>

My first thought would be to create a memory tag that's holds a value set by the buttons.

I.e.

Button 1 selected:  
Memory tag = 1  
Class = x if memory tag == 1

Button 2 selected:  
Memory tag = 2  
Class = x if memory tag == 2

Etc

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [August 23, 2023, 6:37pm UTC](https://forum.inductiveautomation.com/t/perspective-flexrepeater-question/78301/3 "2023-08-23T18:37:17Z")

</div>

Not with tags, tags are gateway scoped and this is clearly session-specific.

Use custom properties on the repeater itself, and bidirectional parameters.  
Though I'm not sure I understand what you're trying to do...

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [August 23, 2023, 6:39pm UTC](https://forum.inductiveautomation.com/t/perspective-flexrepeater-question/78301/4 "2023-08-23T18:39:42Z")

</div>

> [@Ryan\_Allen](#):
>
> ... create a memory tag that's holds a value set by the buttons.

That has the problem that it will be shared by any other instance of the Perspective application running on another device. Great confustion may result.

Instead, use the view's or the flex repeater's custom properties to create a variable to share the current active button number.

---

<div class="post-metadata">

**Author:** ![Ryan\_Allen](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan_allen/32/47013_2.png) [@Ryan\_Allen](https://forum.inductiveautomation.com/u/Ryan_Allen)\
**Post date:** [August 23, 2023, 6:40pm UTC](https://forum.inductiveautomation.com/t/perspective-flexrepeater-question/78301/5 "2023-08-23T18:40:27Z")

</div>

I assumed that was the intention but definitely a good point to bring up!

---

<div class="post-metadata">

**Author:** ![Babla\_Bogam](https://avatars.discourse-cdn.com/v4/letter/b/ecb155/32.png) [@Babla\_Bogam](https://forum.inductiveautomation.com/u/Babla_Bogam)\
**Post date:** [August 23, 2023, 6:42pm UTC](https://forum.inductiveautomation.com/t/perspective-flexrepeater-question/78301/6 "2023-08-23T18:42:27Z")

</div>

How do we share the flex repeaters custom property with the instances?

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [August 23, 2023, 6:45pm UTC](https://forum.inductiveautomation.com/t/perspective-flexrepeater-question/78301/7 "2023-08-23T18:45:36Z")

</div>

Pass them as parameters. And make those parameters output AND input so they can send back data.

---

<div class="post-metadata">

**Author:** ![carlosbqz](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carlosbqz/32/52324_2.png) [@carlosbqz](https://forum.inductiveautomation.com/u/carlosbqz)\
**Post date:** [August 23, 2023, 7:20pm UTC](https://forum.inductiveautomation.com/t/perspective-flexrepeater-question/78301/8 "2023-08-23T19:20:40Z")

</div>

I was thinking of a message handler from the instance to the flex repeater and one from the flex repeater to all the instances, but I don't know if that is a bit overkill 😆

---

<div class="post-metadata">

**Author:** ![Babla\_Bogam](https://avatars.discourse-cdn.com/v4/letter/b/ecb155/32.png) [@Babla\_Bogam](https://forum.inductiveautomation.com/u/Babla_Bogam)\
**Post date:** [August 23, 2023, 8:16pm UTC](https://forum.inductiveautomation.com/t/perspective-flexrepeater-question/78301/9 "2023-08-23T20:16:51Z")

</div>

I am not sure if this this is the best solution but this worked for me. This is how I worked.

1. Created a customer property on the flex repeater called current\_index
2. On the flex instance (basically just a button) when user clicked then using message handler send message to update the current\_index in step 1 above
3. Then added a onChange script on current\_index from step 1). In this change script using another message handler send the currentValue to the flex instance. So flex instances are aware of the current index

---

<div class="post-metadata">

**Author:** ![carlosbqz](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carlosbqz/32/52324_2.png) [@carlosbqz](https://forum.inductiveautomation.com/u/carlosbqz)\
**Post date:** [August 23, 2023, 9:00pm UTC](https://forum.inductiveautomation.com/t/perspective-flexrepeater-question/78301/10 "2023-08-23T21:00:11Z")

</div>

That is exactly what I did 😅

I wasn’t able to make the instances parameters to update without the script running all over again, so I thought that the solution would be a adding a message handler from flex repeater to the instances.

Hopefully this is the best solution to your case 🙂 🤔

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [August 23, 2023, 9:03pm UTC](https://forum.inductiveautomation.com/t/perspective-flexrepeater-question/78301/11 "2023-08-23T21:03:26Z")

</div>

Why don't you just modify the CSS class rule for selected buttons - perhaps even only those with a specific class? Then you don't have to maintain any registry or book-keeping.

```auto
.psc-MyFocusClass:focus {
    bottom-border: 3px;
}

```

Edit #1: Actually you may just be able to do this within the Named Styles, without needing to include the stylesheet.css resource by specifying the state for the class.

Edit #2: Unless you are clicking somewhere else _after_ having clicked the Button... at which point you will need to "register" the Button last clicked.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [August 23, 2023, 9:55pm UTC](https://forum.inductiveautomation.com/t/perspective-flexrepeater-question/78301/12 "2023-08-23T21:55:46Z")

</div>

> [@cmallonee](#):
>
> Unless you are clicking somewhere else _after_ having clicked the Button... at which point you will need to "register" the Button last clicked.

I think that’s the whole point.  
But I feel like messages are a bit over complicated for this case.  
I’d suggest a different method but I’d rather make sure it works first, I’ll try it tomorrow and report back.
