I have an coordinate container and i want to add a new component (eg label component) with script. Like when a button is pressed a new label component will be added. I have seen this in one project but do not know how to do it.
No. You could create a parameterised view containing a label and then use a Flex Repeater to increase the number of instances.
Can you describe the real problem you are trying to solve?
I'm just trying to add a new label or text component component on the screen. Something like microsoft notebook.
Can you explain a bit detail about what you said before
I can't find any web reference to a "Microsoft Notebook". Do you mean OneNote? If so, then no.
Yes OneNote
My Bad.
What use is that?
Again, can you describe the real problem you are trying to solve? What kind of application are you trying to make?
just trying to add components with script.
If this thing is achieved then i will move forward to build something
Use a flex repeater and add/remove instances as needed.
This is a great example of XY problem.
Flex repeater won't be suffice or useful in this case as every instance will be created at the flex repeater component level. I'm trying to do is to add component at view level.
If we copy component and paste it in notepad we can see the structure of that component. I was thinking if we can modify some properties like name and property and then append it in the view structure.
You said you wanted to add a label by clicking a button, no? The flex repeater will work for this. You create a view with a label and with a parameter for text. When you click the button a new instance is created in the flex repeater. You can use a database, tag, or maybe global variable to store these instances if want things to be retentive in nature.
It sounds like you have blinders on and are only interested in someone giving you the answers to what you think the problem is.
There's no mechanism in Ignition that would let you do this. The only thing that could possibly do this is directly modifying the view definition in the gateway filesystem and waiting for the gateway to notice that you did so.
(I would recommend the view canvas instead of the flex repeater to solve your actual problem, but either method provides runtime support for dynamic structure in your view.)
I think you could use the following instead of waiting for the system to update on its own.
I created a component - 'Text field' and made it visible on button click.
At this point I saved the all the required properties of this new TextField in a new memory tag of this
opened the exiting view.json file modified it and saved it with the different button click script.
closed the session and then relaunched the session and it was showing the new compoent.
The only thing was I have to wait for the gateway to update the project.
I will now make use of requestScan and see