Perspective FlexRepeater custom

Hi,

I have problem with my Flex Repeater
I’m using a view who repeat x times in my flexrepeater, through this view i’d like to make a onclickevent wich will modify one of custom values of my flexRepeater.

But I don’t know how to acces, this is what i’ve try

image

This is my tree :
image

The onclick event is on “Templatemission\Root” and my custom is on the flex repeater ( “OI/Home_OI/FlexRepeater”)

There are two options here:

  1. You can either place an outgoing param on the Templatemission View, and provide a case-sensitive matching named param for the FlexRepeater instance, which would provide your FlexRepeater access to the value form the internal View instance.
  2. Whatever you are clicking in the Templatemission View could broadcast a message with system.perspective.sendMessage() at the page or session level, and then your Flex Repeater would then need a listener configured (right-click the FlexRepeater, then select “Configure Scripts” and create a new listener where you provide a message type key which matches the one configured in the Templatemission View).

I recommend the system.perspective.sendMessage() solution, as binding a FlexRepeater value against an indexed instance is not going to be fun.

This actualy what i’v done, but not working :confused:
Because i can’t get the syntax for modify the flex repeater custom from TemplateMission onclick script

I gonna try the system.perspective.sendMessage() solution, thx

Can you explain me how system.perspective.sendMessage() works ?
I never used it before

Thanks

Depending on where you’re accessing it from, it would be something like

self.view.rootContainer.getChild('FlexRepeater').props.instances[x].param_name

.getChild('FlexRepeater').custom would be referencing a custom property on the Flex Repeater, not one of the internal instances.

I don’t think self.parent.parent.getSibling('root') should work, as a “root” will never have a sibling. A View’s structure MUST always be View(1) -> root(1) -> Components/Containers(0 - some number we haven’t determined yet)

I’d like to access from my TemplateMission view
So is it possible to access one of flexrepeater custom from TemplateMission ?

Ah, okay, so you’re trying to reference a property on your FlexRepeater from WITHIN one of the internal instances?

Short answer: no, you can’t - templates (Views in Embedded Views or Flex Repeaters) don’t know about the structure of their parent

Long Answer: Yes, of course, but you need to bind FlexRepeater.props.instances.input_param_name to the property on the Flex Repeater. This will allow the Template Mission View to be supplied with a value from the Flex Repeater. The problem you will run into is if you’re trying to write BACK to the Flex Repeater value, as if MULTIPLE instances are bound to the variable then how do you know which instance wrote to it?

What I would recommend is pass each instance of Template Mission a param (“instance_number”) which is its instance number. Whatever trigger you would use to fire the onClick Event should use

system.perspective.sendmessage(
    messageType='TEMPLATEMISSIONCLICK',
    payload={'instance_number':self.view.params.instance_number},
    scope="page")

Your Flex Repeater should have a custom property named “instance_number”, and a configured listener which is listening for the “TEMPLATEMISSIONCLICK” message type at the Page scope, with a script of self.custom.instance_number = payload['instance_number']

Using the posted method will allow you to see which of your instances was most recently clicked.

2 Likes