8.0.12 Perspective Property Reference Grandparent

Hi all,

Was just wondering if it is possible to reference grandparent properties in perspective. Tried to find the info in the documentation but couldn’t see it.

I tried {parent.parent.custom.myProperty} but that doesn’t seem to work. Selecting from the property browser gives me {…/FlexContainer.custom.myProperty} which won’t work for my application. Ideally I would like to reference it without needing to specify the grandparent container (FlexContainer) in the same way that parent.custom.myProperty would work.

It depends on if you’re using a Script or a Binding.

Let’s use the following example:
Screen Shot 2020-06-22 at 7.23.58 PM

If I’m attempting to bind the Label’s props.text to it’s sibling, “NestedButton”, then the binding looks like

../NestedButton.props.text

If I’m attempting to bind against the Button which is within “FirstFlexContainer”, the binding would look like this:

..../Button.props.text

To make sure your bindings are always resolving to a value, I always recommend using the property popover to select an available property; it’s the icon all of the way to the right of the binding input field:
Screen Shot 2020-06-22 at 7.28.38 PM
It will never let you down (unless you change component names at some point in the future) and provides an easy to parse property tree:

Scripts look entirely different, and there’s a bit of variety in how you can do it. This page in the documentation lays everything out pretty well, but even in scripting you have the ability to use the property popover I just mentioned.

This following script would set the Label’s text to that of the non-sibling button:

self.props.text = self.parent.parent.parent.getChild("Button").props.text

Now, in your example you claim that the binding path the popover provides won’t work, but not why that won’t work. Component paths will never change at runtime (only within the Designer through user action), so that selection should work 100% of the time.

Thanks @cmallonee, it is a binding, so it looks like I can’t get it to work without naming the component itself. The reason I wanted to do this was because I had a custom property that I wanted to use to update several bindings, but I didn’t want to create an embedded view for it. Every copy paste would change the name of the component which would require updating the bindings anyway. Nesting within another container works to keep the reference constant, I was just hoping there would be something similar to the parent shortcut.

You could move the property to a session property.

A binding of self.session.custom.myProperty could be copied and pasted onto any component without faulting.

Locate the Grandparent property you want to use across several other components, and bidirectionally bind that property against a session property. Then bind all of those other components against the session property. This allows you to have one central value which updates based on the grandparent component, but which you can also paste a shared binding onto multiple components without worrying about faulting due to a differing binding path.

Or use messaging, within the view?