I have a need to create all the plc device status for everyone to view. It can be viewed on the gateway, however I do not want to give everyone access to gateway. this is how close I got. Using this script I got all the list of devices.
json format as below
You can use a script transform on a binding for the flex repeater and programmatically build the json to create instances in your flex repeater. The binding executes when the page loads. Based on your script it would look at the tag database and make as many instances in the flex repeater as you need.
Bind to whatever condition you want to use to make it load content. Then use a script transform on the binding to build the json that loads instances of your view inside the flex repeater.
If you only need to update the list when you open the view, then you just need to use the onStartup event on the root view. You can right click on Root > Configure Events. Then add a script there
Then I would use your same script, but instead of printing it out, just assign it to a custom property
so replace
print device_list
with
self.view.custom.deviceList = device_list
Then, you can bind your flex-repeater's instances to self.view.custom.deviceList
Bonus, you can create a new script under Root > Configure Scripts and name it refreshDeviceList
then you can call it from the onStartup event like this
self.view.rootContainer.refreshDeviceList()
This also allows you to create a button to call the same script to refresh your list without having to refresh the page
I wouldn't use an onStartup event. I would use a binding with a script transform regardless if you want to run it on load or on change of something, as then it's directly attached to the component and is obvious. Something in an onStartup script is less obvious.
If you just want it to run once, use an expression binding and set the expression to simply 1
You should just be passing the devicePath to the template views and indirectly binding to the tags you need to read from within the template views.
Thank you @vtran & @nminchin for your help. It worked great, now I have a beautiful table dynamically populating and giving connection status of all PLCs. However I ended up using on startup. @nminchin is this what you mean ? I thought transform was to modify the value. How 1 can be transformed to pull the data script ?