Hey was experimenting in perspective scripting and was wondering if there is a way to add views via button click
I know that this exists https://forum.inductiveautomation.com/t/editing-or-creating-a-perspective-view-via-script/50511?u=matthew_breeding
however I was wondering if I could use like self.children.append() except I cant seem to get it to work. Is the above link the tried and true method to generate views dynamically?
There is no supported way to create views dynamically. Creating raw resources on the filesystem is certainly possible, but I would argue probably not necessary. Whatever your ultimate goal, it would be much easier for you to maintain if you work within the bounds of our existing components, such as the view canvas or flex repeater.
Ok that makes sense, my goal was to have a tab container empty and then somewhere else on the program I wanted to click. Once clicked I wanted to generated a number of tabs in the tab container based off of the data in the original click. flex repeater could work however each embedded instance of my view takes up the entire screen so I am worried it will ruin the flow of the program
You could use a carousel and populate it dynamically.
Or you could use parameterized views in a tab container. If the data you want to display is generic enough that it can be handled by a handful of views, you don't need to generate those at runtime, just instantiate one that already exists.
Also note that you don't need to embed views in a tab container. You can use a container for each tab.
hmm, this might be the best option for me I have yet to use this component. Thank you for your suggestion
If you need "named tabs" to navigate to a view directly in your carousel, you can use a flex repeater to generate buttons, use the buttons to send a message handler with the instance number in the payload, and put a message handler on the carousel to navigate to the proper view when it receives a message.
That's smart I will make some modifications to your idea but the idea is great and something I think I will implement. Thank you for your time and your suggestions. Couldn't Have thought of this with without ya!
It is definitely possible to make a robust and dynamic system with Ignition! perspective. We have one project where all of the screens are just base templates, flex repeaters or chart components without content and the user configures them when they login. About half are driven by user interaction which manipulates the components props, some are driven off of tags or queries that run on a timer. Most configurations are stored in a DB and loaded when a user comes back to a previous session.
There are quite a few creative ways to make the system do what you want through scripting.