Version:

LESSON

Expression Structure Binding

Description

Learn how to configure a binding to an object based on a number of expression bindings.

Video recorded using: Ignition 8.0

Transcript

(open in window)

[00:00] Project properties in Perspective are configured as JSON and are designed to allow for nested data structures. In light of this, Perspective offers a binding type for efficiently handling nested data, called the Expression Structure binding. The Expression Structure binding allows us to create a data structure using expressions to populate each entry in the structure. To demonstrate, I have a Carousel component here, and within the Carousel component I have a nested View called My Child View. Now this is working just fine, except our View is expecting two parameters, which I have not yet provided. Now if I'd like I could simply come to the viewParams property and enter them as values, but I'd like to try a slightly cleaner approach using an Expression Structure binding. So to do this I'll click the binding icon, and I'll select an Expression Structure binding. This binding will allow us to populate any Object property with nested Arrays, Objects, or Values. In this example I just need two Value parameters. So I'm going to select Add Object Member, and I'm going to select Value. The first parameter I'd like to specify is called iconPath. And I can assign to iconPath any expression. So I select the Expression Builder icon, and the expression I need will simply be material/insert_emoticon. All right, now I click OK. Now I need to add a second value to our structure. So I'm going to make a little bit more room, and I'm going to click the plus icon here, and I'm going to select another value. This one needs to be called labelText, and this value I'd like to fetch from a tag. So coming in here I'm going to remove the value, and I'm going to select the tag icon, I'm going to navigate to My Tag, and I'm going to click OK. And then I'm going to click OK to save. So now the label text that I'll be using in my child view will be populated from this tag. So in addition to our standard options, like enabled and overlay opt-out, we have a check box called Wait On All which will prevent the binding from populating the object until all nested values have been successfully fetched. Now if I'd like, I could add a transform, as long as I use a script transform here. And in here the value parameter will be a dictionary. So I could, for instance, reference the iconPath property... like this. Now I don't need a transform right now so I'm just going to click the trash can icon to remove it. And this completes the Expression Structure that I need for my viewParams property. So I'm going to click OK, and as we can see the view is populated with the parameters I configured.

You are editing this transcript.

Make any corrections to improve this transcript. We'll review any changes before posting them.