G Web Development Software

cancel
Showing results for 
Search instead for 
Did you mean: 

Access current value at selected array index

Solved!
Go to solution

After a specific array index is selected, how does the code access the array value at the selected index?  I don't see an index property in the array type.  Thank you.

0 Kudos
Message 1 of 11
(734 Views)

Just to clarify, for an array control on the panel are you asking for the current value of the indexers, i.e. similar to the LabVIEW Index Values property?

MilanR_0-1717532267604.png

 

Can you describe a little more about the behavior you are trying to achieve? I suspect you could use the JavaScript Library Interface to retrieve the value but curious what the workflow is to know if just being able to read the value is what is needed.

 


Milan
0 Kudos
Message 2 of 11
(702 Views)

Hi Milan,

 

Yes, similar to the LabView Index Values property as long as it provides the current index value of the array.  I've an array of text strings which are populated by retrieving file names with a specific suffix using a web service.  The user of the G Web App then selects which of the file names is desired, and that is to be supplied to another web service.  So when the user scrolls through the populated string array, whatever index is the currently displayed file name is the file name that I need to supply to the second web service.  The current solution is to have a numeric control right next to the string array indicator, and select which string array index is desired using the numeric control after scrolling through the available file names in the string array.  That's not optimal from a user experience; in fact it's quite awkward.

 

Thanks for your quick response, and I'll await your suggestion(s) on a better approach.

0 Kudos
Message 3 of 11
(693 Views)

The context is helpful, thank you! For having an array of strings where the user needs to perform selection I think you can get a better experience using the Tree control. You'll have to transform the data a bit to be an Array of clusters of strings but then the Tree control itself supports selection modes such as single / multiple as well as change events for when the selection changes as well as property nodes to see the current selected values.

 

treecontrolselection.png

 

 

treeselect.gif


Milan
0 Kudos
Message 4 of 11
(681 Views)

Thank you.  Can you point me to an example using the Tree Control?

0 Kudos
Message 5 of 11
(677 Views)

Updated my last post to show an example and you can also see the Tree control docs.


Milan
0 Kudos
Message 6 of 11
(668 Views)

Thank you very much!  I'll come back if I have further questions.

0 Kudos
Message 7 of 11
(661 Views)

Okay, I'm doing something wrong.  I can't initialize the string cluster like you did statically; it needs to be built dynamically after the web service returns a comma-separated list of file names.  This is what I have so far (the array logic is the current approach). I added a Tree containing a string indicator (this may be incorrect).  Where am I going wrong?

 

Snippet.png

0 Kudos
Message 8 of 11
(647 Views)

By default the Tree uses the value written to a terminal to determine the wire type, i.e. how many strings to expect in the cluster.

If you don't use the terminal to set the initial data then I think the default is a cluster with two strings.

 

You can specify how many strings to expect by

  • wiring an initial value to the terminal or
  • by unchecking Columns auto adapt from terminal and manually specifying the number of expected columns (one column per string in the cluster).

 

MilanR_0-1717551482222.png

 

Also, looking at your snippet it seems like the selection will be for file names, if you expect "\" characters in the strings please note that backslash characters ("\") in the first column / first string of the cluster are treated as paths and used to build a hierarchy. It's possible that:

  • The hierarchy feature is useful for representing your data
  • The hierarchy behavior is undesirable, so instead maybe make a cluster of two strings where the first string represents data that does not include a path, like an index.
  • The hierarchy behavior is undesirable, so you escape slashes in the strings to avoid showing the strings in a hierarchy as discussed in the Tree docs.

Milan
0 Kudos
Message 9 of 11
(617 Views)

I've been unable to dynamically build the Tree Control with file name strings, so for now I'm going to leave it as a numeric control right next to the string array indicator even though it's not a great solution.

0 Kudos
Message 10 of 11
(467 Views)