Hi,
I have followed this guide: Turn Perspective Table Columns into Dropdown Menus - Ignition by Inductive Automation - YouTube
I'm no expert on Ignition so I'm stuck on how to define what numbers and labels will be. Youtube author wrote: "You want an array of json objects, each with a 'value' key and a 'label' key. You can hard-code the param, bind it to a SQL query, or assign the value using a startup script."
How do I do this the easy way?
/Tim
What exactly is the problem you're trying to solve? It seems that you are trying to add a dropdown selector in each cell in a Perspective table column to restrict users' input to predetermined values.
You have the word "menus" in the linked article. I assume that you're not trying to create menus inside a table.
Can you edit your question to clarify and maybe give a sketch or mockup of what you're trying to do?
1 Like
Sorry, my mistake just give a link to a video on youtube.
The tutorial is about that I want a drop down selection in one of my columns.
My goal is that I have a value 0-5 and I want the drop down meny in the column to display words that is linked to the numbers. 0 = OFF, 2=ON, 3=REMOTE etc.
I have created a view with a drop down and a script according to the tutorial. Also I have defined som params in the view, one of them is ListOfParameters.
I have added the view to one of my columns and it works so far. But in the columns I have the LisyOfParameters that is blank. So I cannot choose anything, but I dont know how to add either. The tutorial doesnt say how, only a comment about that it should be an array of JSON with value and label
The list of options is just a parameter that you need to fill by yourself to create the option in the dropdown object. If you use that dropdown only for that, i would rather put the options directly on the options props of the dropdown object in your embedded view.
Thanks!! That did it
Only problem now is that the tag binding doesn't change when I select a value in my dropdown
Without some print screen or code we can’t guide you to a solution…
This is all taken from an tutorial from youtube so I don't have to advance knowledge about it.
When I press the dropdown the selections appear. I can press them but nothing happens with the value. In the example I pressed OFF which should be 0. If I instead enter the number and press enter it does change the value, but the dropdown selection does not change accordingly. I would also like the drop down selections to change if the values are change from somewhere else. I attach a screenshot of what I think is a beginning to what you need
I noticed the script on the dropdown got croped: scope='page')
in the action performed script, messageType is updateColumn in the message handlers is UpdateColumn. those need to be the same.
also I see that you're using rowIndex as parameter becareful that this return the row number of what is visible at that moment in the table. so if you use a filter it can return row 0 because it's the first one visible on the table but it can be row 10 in the source data. you should use row instead on row index.
viewParams = {
...params, // Merged params listed in the column configuration object of this column
column, // The column name as defined in the field property of the column configuration object
columnIndex, // The index of the column
row, // The true index of the row relative to the source data
rowIndex, // The visual index of the row relative to sorting, paging, and filtering
value, // The value of the table cell
rowData // The entire rows data as a JsonObject
};
Now it kind of works.
It adds a new object member in the data called "value". So I have to bind this to my tag. But I already have a object member called Batteri that is the column name. Not a big deal if it works.
But idealy the selection list would also update when the tag changes externally, is this manageble?
if it add a member that means something is wrong. I'm pretty sure that on your embedded view params you write Column and not column.
for the update on tag change if you bind the view param value to the value props of the droplist it will update on tag change.
I had to configure a value in the columns of selection of the table and it worked.
But I don't get the update on tag change. I think I have bind what you mean. But when the view load it just show "select..." . I can see the tag is a 3, and when I press the dropdown it is indeed a 3. But it doesn't show the text coresponding to the value.
could you export your view en share with us. we can then take a look to it
under the view params rename your params like on the above picture.
you will need to remake the binding between the dropdown and the value params also in the on action perform on the dropdown the change self.view.params.Column to self.view.params.column
under the columns settings of your table set editable to false so the operator can only select a value from the list and not entering a number you can also delete the Column in the viewParams.
viewParams = {
...params, // Merged params listed in the column configuration object of this column
column, // The column name as defined in the field property of the column configuration object
columnIndex, // The index of the column
row, // The true index of the row relative to the source data
rowIndex, // The visual index of the row relative to sorting, paging, and filtering
value, // The value of the table cell
rowData // The entire rows data as a JsonObject
};
You were pretty close, only two issues in the dropdown view param Column should be column and Value should be value.
Beware that Ignition is case sensitive for the most part of it.
Hope this help
Thank you very much for the help!
It seems to be something strange with this drop down, I'm not 100% sure but it seems like a drop down selection in one table also take effect on the second table. The bindings in the "data" are set to diffrent tags in the two tables, and when I change the values from the PLC only one table changes. It leads me to think that two update script on the table somehow take effect also on the other. Can it be so? I can't find it to be wrong in any other place
if those tables are on the same page, yes it will cause that behavior.
the on action event send a message update and if both table have a message handler with the same name. both will execute the update code.
Ah thanks! So I made a copy of my "drop down view" and changed the updateColumn to updateColumn1, and changed name of the script on my second table. Working now
You could give the name as input parameter of your dropdown view. so you only have one view to maintain.