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
system.perspective.navigate(
'/tank/detail',
params={'tank': self.view.params.tank})
in your template's onClick script.
Either that or have your message handler do the navigation. The params argument would look more like params={'tank': payload['tank']} in that case.
1 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).
This view (the embedded view for each flex repeater instance) should have the onClick event on it’s root