Dynamic custom property selection, how to go about it?

I have a custom prop object with about 20 bound tags, incoming to the view. There is a table displaying basically what those tags are that can be updated with a new value. When I click or tap on a table row, I would like to get the value from the custom prop and send it to a numeric input field where I can change it. The setup is like this: each value in the custom prop object is numbered G1 through G26. The row number in the table will correspond to the custom property number, 1 - 26. So I'm thinking I should build the custom prop string via script in the onRowClick event, but I'm not sure how to turn the string back into a object reference like {string}.

this is the data object JSON:

{
  "G27": "value",
  "G28": "value",
  "G7": 85,
  "G9": 77,
  "G13": 626.4,
  "G8": 96,
  "G26": true,
  "G19": 79,
  "G2": 100,
  "G1": 7.9999995,
  "G21": 23,
  "G5": 66,
  "G23": 43,
  "G3": 1.5000001,
  "G12": 11,
  "G6": 6.000001,
  "G10": 97,
  "G11": 13,
  "G24": 95,
  "G20": 90,
  "G25": 17.699999,
  "G16": 70,
  "G4": 17.499994,
  "G22": 40,
  "G18": 91,
  "G17": 14.999996,
  "G15": 8,
  "G14": 80
}
path to the object: `root.custom.temp_data`

Here is a screen shot:

Is it possible to build a string for each path to G#, like var = 'root.custom.temp_data.G' & rowNumber?
Then turn that into the actual reference? Because, the numeric input box is bound to a custom prop, so I am hoping to set that equal to the above-mentioned property.

Or am I doing this all wrong?

I'm also going on maybe 4 hours sleep, crossing my fingers I explain the problem and ask the right questions, lol.

EDIT: I suppose I could get the value from the tag via a dynamic script call, but I already have the values pulled into embedded views so the user can compare the last/current value to the new value. EDIT: I just realized the tag paths are not conducive to be dynamically constructed.

And Here is my edit section:

In this example, the temp_data property will behave exactly like a python dictionary. So your scripts would access the appropriate keys just as you would any other dictionary.

Use the property selector to get the appropriate path to your custom prop.

temp_Data = self.custom.temp_data
gNum = 'G{}'.format(rowNumber)
#to read data
value = temp_Data[gNum]

#to write data
temp_Data[gNum] = value
2 Likes

Aaaargh!

Right justify the numbers!
Left justify the units!
If one of the psi values has decimals then format all the psi readings with decimals so the decimal points line up!

1 Like

The numbers and units are one string, via concat expression.

I knew it was something simple. Thank you!

So self.custom.temp_data is passed by reference to the temp_Data? When I write is back, as you suggested, the original value changes.

Essentially yes. If you want a copy, you have to explicitly make that copy yourself.

1 Like

I added extra decimal places, text align right, and 2em padding on the right.
The display component is an embedded markdown with some html to provide the bold text. I tried adding spaces, but I think I need to use markup or html to make the spaces show.

I'm guessing that you're using a table with one column rendered as a view and that view has a markdown component. If so, then the alternative is,

  • Create a view with two parameters, value and engUnit.
  • Add two labels to the view and bind these to the view parameters.
  • Use style classes rather than direct formatting on the labels. It will enable you to be consistent across the project and make style changes easy.
  • Use the new view as the rendered view in the table column.

You can't use spaces or padding to align stuff when using variable width fonts.

Actually it's just a label in the embedded view, with a few parameters. So, each value you see is a label in an embedded view:

Now that you mention a table, perhaps that would be a better option - for performance and efficiency.

... And then you can use separate columns for the values and labels.

1 Like