My goal is to determine which instance of a flex repeater the user has clicked on and navigating to a new screen, pass either the index of that instance or the instance tank property through a custom property on the flex repeater. My flex repeater instances successfully update to show the accurate index data so my assumption is that my instance properties are accurately defined, but the view.param.tank does not update to match the tank property of the selected instance, so whatever value I left in the designer as the value for view.param.tank is assigned to the custom property on each click.
I have been referring to a few similar examples on this site where this design seems to work, so I’ve included screenshots of all the information I think is critical to this page’s architecture.
Use system.perspective.navigate to navigate to the new page based on your selection and pass the necessary parameters to the page as part of that call. You would have something like
Thanks for the quick reply, this is super helpful but I should have been more specific with the root of my issue currently.
Making references to self.view.params.tank parameter has been futile as this parameter does not change in my project. For an example, say I define the parameter in my designer as view.params.tank = 3. The value does not matter, because the flex repeater instances have their own definition of an instance property = tank: __. Whenever I execute the onClick and message events, self.custom.selected becomes equal to self.view.params.tank, but that parameter is still equal to 3. So I don’t get any useful data to determine what instance was clicked.
Based on what I’ve seen as a solution on here, self.view.params.tank would hold the index of whatever flex repeater component was selected (please correct me if I’m wrong here), which is passed to a custom property or in your example as a navigation parameter. But in my case the self.view.params.tank value never updates despite flex repeater instances accurately populating.
Okay I just discovered where my mistake was! I’ll include the solution in case anybody else runs into the same bug, though this was a pretty basic overlook on my part:
My onClick script was configured on the root of the same view as the flex repeater, in which the view.params.tank parameter is unused so of course the value is never altered. Where this onClick script should be configured is the view that is accessed through the flex repeater. This view has received the instance property as the views parameter, so a reference to this parameter will be the same as that instances tank property (at least in my design architecture).
Use a unique parameter.
There's one that's built-in, I think it's index or instanceIndex. Something like that.
You'd still have to create it in the repeated view, but its value is passed automatically.
This may not be unique if you have nested repeaters, in which case you'll need to find something else. I used uuids in the past for that.
Send that unique identifier in the payload, so you can identify which instance was clicked in the message handler.
Why not handle this at the "template" level? The template instance in the repeater already knows which instance it is. Just add a navPage parameter that is default none. Then if no string is provided disable the navigation, if a page is provided handle navigation to that page within the template scripting.