Good day. I am looking at creating a general template for a popup that i can use multiple times over. I have a base view created that looks something like this:
I would like to be able to select one of larger squares and it popup a window with that information for the position.
Which component would be good for this? Would I need to have the squares have some value that passes to the popup?
Thanks for the help
This varies greatly with what information is contained in each of those little squares and where it comes from, but from a quick glance, it looks like the Pos number of each square is unique (?), so you may be able to leverage that as a parameter you pass into the popup. Even if the Pos field isn't unique, there should still be a way that you're differentiating one Pos from another - use that in the popup to query a record from a DB, read a tag, or whatever action you need to take to get that specific square's information.
This is a very common paradigm I use all of the time (esp if you want to reuse components).
If you every square has the same properties, you can just pass the property (for example ".value") as parameter to the popup.
It will be in perspective. The information will be same in each square, just different positions. I think Im hearing I should give each one of these squares a custom property and push that property into the popup via script?
I just tested my method, it worked. You can pass property to popups. In perspective, you cannot group it, but you can still put objects in a container.
Do you mind sharing your method? Thank you
Have you seen this lesson on inductive university?
I had not seen it yet. Thanks
1 Like
I think I got what I want for this. I made a custom property for each of the squares and had it write to a custom.session property. From there on the popup I gave it a parameter that looked at the custom.session property, then used that to do indirect addressing so it would fill in the indirection and grab the tags I needed to display.
What i would do is first have my tags organized in a folder where each "Pos" is an UDT instance, currently i'm in a project where i have some buffers so i have an UDT instance with all the info for each buffer position like this:
The second thing i would do is name each square with "Pos" + it's number so it matches what my udt instances are called, like this:
Third, i would select all of my squares, press CTRL + J to open the event configuration window for all of them and add this action under either "actionPerformed" or "mouseClicked", this will toggle open a popup and pass the name of the square clicked to a property called "PosString" on my popup.
And finally, i would make a indirect tag binding to the root of the UDT so i get all the info about the Pos on my popup, the indirect value will come from the parameter passed to the popup from the script on each square:
My pos numbers are sequential, so every time i can make one square with everything i want and then just copy it and place on my screen, ignition will automatically name it with the next number, if i make Pos1 and copy and paste it on the same screen, it will already be named Pos2 for me so i don't have to worry about the custom property of each square.
1 Like
Fwiw, I would always pass in the tag path to the Pos UDT instance to the template and into the popup. E.g. in Leonado's example, I would pass in "[default]Buffers/Pos1" into the popup. I would also pass this tag path into the template graphic itself, rather than passing in simply the "1", "2", etc.
When I first started using Ignition, I did used to pass in things like parts of tag paths such as an integer index, but I found a lot of the time this would come back to bite me as I would then need to use the template for another area or multiple areas with different tag path structures, so the paradigm no longer worked, or was difficult to accommodate for.
In the end, I replaced this with simply passing in the full path to the UDT instance into all of my templates and parameterised popups that display info for a UDT instance. This also allows you to use the props.dropConfig
to enable you to drag UDT instances from the tag browser onto a View to add embedded views to the page that have their parameters auto-configured.
7 Likes
I used UDT for my project too.
For his/her example, it he/she does not want to change the squares, and all he wants to do just add event to open popup; he can use script or popup to do it. I learnt from other guys here that using event-script is better than event-popup.