Page 1 of 1

Inserting a Reference Field with a theme or widget

Posted: Fri Mar 31, 2017 5:48 pm
by TomM
I want to insert a reference when a screen is converted using my custom theme.

For example, I want to insert the reference 'TTLPGM' into the tooltip property of an element when I am converting a screen.

If I just do:

Code: Select all

item["tool tip"] = "TTLPGM";
It just changes the tooltip to the plain text: "TTLPGM" as I would expect.

How do I tell the theme that I want this to use a referenced field?


Thanks

Re: Inserting a Reference Field with a theme or widget

Posted: Fri Mar 31, 2017 10:04 pm
by Scott Klement
Do you mean that you want the "tool tip" property to be bound to a character field? If so, you'd do this:

Code: Select all

       item["tool tip"] = {
         dataType: "char",
         dataLength: "50",
         designValue: "[TTLPGM]",
         fieldName: "TTLPGM",
         formatting: "Text",
         trimLeading: "false",
         trimTrailing: "true"
       };
In this example, a character field, 50 chars long, will be created named TTLPGM that will be bound to the tool tip of the item. (I assume you know how to get the "item" var for the field you want to change, based on your message...) This bound field will be formatted as Text, and trailing blanks will be trimmed when the DDS variable is assigned to the tool tip.

The "designValue" property is what will display in the visual designer.

If by "reference" you mean that you're using a reference file (i.e. using the REF keyword, and want to pull the definition from the referenced file) then you do it very similarly, you just set the dataType to "reference", and do not specify the length.

Code: Select all

       item["tool tip"] = {
         dataType: "reference",
         designValue: "[TTLPGM]",
         fieldName: "TTLPGM",
         formatting: "Text",
         trimLeading: "false",
         trimTrailing: "true"
       };
Hope that helps