Set label value in template based on parameters

Hi

I’ve created an UDT type, and now I’m designing a template to show the information.

I’ve defined a template parameter named “input” of MyType, and I’m binding a TextField with Indirect Tag using {1}.field and 1 = MyTemplate.input, but still I see no value when I drag and drop an instance of MyType using MyTemplate.

I have 3 questions here:

  • Why can’t I see the data in the TextField?
  • Can I show the field value in a Label as well? (I don’t know if there’s any way to bind a Label to the “input” parameter)
  • I’d like to show a description of the instance in a Label inside the Template. Essentially is the same case as the previous question, but using a second parameter, which I would set every time I create a new instance.

Regards

Hi Freddy,

Indirect tags work with tag paths (represented as strings), while dragging and dropping sets the actual reference to the tag, and allow you to work directly with it (though indirect tags tend to perform better).

So there are two options:

  • Work with indirect tags:

  • Make sure the data type of the template parameter is a string

  • Right click on the parent tag in the tag browser, and copy the “tag path” to that template parameter (drag and drop isn’t possible here).

  • Use indirect binding to append a field name to the parent tag. Do ensure that, when the indirect binding is filled in, the resulting string is a correct path to the child tag

  • Work with UDT parameters:

  • Ensure that the data type of the template parameter is a “User Defined” datatype, pointing to your UDT definition

  • Drag and drop the tag to the template parameter

  • Use the “properties” browsing instead of indirect tags to display the field in the label

So in the first case, you just know the tagpath of the parent tag, then construct the tagpath of the value you want, and get that value to display. In the second case, the template has a reference to the entire parent tag already, and you can simply browse the properties, to read or write them.

If you need anything more complex, you’ll probably need an expression binding, which allows you to concatenate certain parts or do calculations on them before displaying it.

If it is just manipulation of the tag path, you should use a second, computed, tag path string, then use indirect binding. While the tag() expression function looks convenient, expressions can’t be optimized as thoroughly as indirect bindings.

Hi Sander,

I think the second option looks better. However, I don’t see the way to make it work.

After having defined the “input” parameter of “MyType”, I selected the label and then the “value” property in the “Property Editor” (bottom/left in the Editor). In the binding section I go to “Property” where I can choose between:

  • Expression -> {MyTemplate.Numeric Label.value}
  • Property -> MyTemplate.Numeric Label.value

I’ve tried to do some changes on both but no results. Is any of these the right place to link the Label with the UDT field?

Regards

Ok, my mistake, I was trying to change the component properties :sweat_smile:

Right now it’s working :slight_smile:

Thanks and regards