Hi,
Is there a way in ignition to input a list of items through one of the components ?
Requirement is from the perspective screen I need to enter some text items (Eg: 'test1', 'tet2', 'test3') through a dropdown or something (which will allow to input and not select from a list) and this need to go to a dataset.
Ultimately, I want to use this dataset in my report.
Please let me know how to achieve this.
You want to convert a list of items to a dataset so that you can assign it to a dropdown, is that right? If you also want to use it in a report (and perhaps multiple places in your application) consider making it a database table and referencing it via a query.
2 Likes
The Dropdown is the best built-in option for selecting multiple values at one time. Within the properties of the Dropdown, set props.multiSelect
to have a value of true
. Doing so modifies the value
property to now be an array of values.
There is, however, no built-in enforcement on the number of options a user may select, so it's your responsibility to handle any number of items within value
.
For example, suppose you have some existing dataset with three rows, but the user only selects two items from the Dropdown... The following code (triggered by a Button press outside of the Dropdown) would break if the values are applied to your Dataset as a new column:
tag_path = "TagPath"
original_ds = system.tags.readBlocking([tag_path])[0]
new_ds = system.dataset.addColumn(original_ds, self.getSibling("Dropdown").props.value) # breaks here because the count of selected items in the Dropdown does not equal the number of rows in the Dataset
system.tags.writeBlocking([tag_path], [new_ds])
Aside from the Dropdown, I would potentially recommend a collection of Checkboxes, where the combined value of the selections is managed through an Expression Binding.
As for how to commit your user's selection, I highly recommend an external input (like a sibling Button) which has its enabled state bound against an equality condition where one side is the length of your dataset (or column count, depending on how this is being used) and the other side is the count of selections made by the user.
Actually, I don't want the user to select from a dropdown. I want the user to enter multiple text items and read it as a dataset or list through any of the perspective UI components. Is there a way other than 'Text area' component to achieve this?
You might be able to have a memory tag as a dataset
Have a text entry field, and a button that will append the entry to the dataset
But I think a dropdown is better if possible, if this is feeding into other parts of your system, typos or other mistakes from the user could affect the system.
Try to copy some standard browser GUI standard that users are already familiar with. Don't make something weird.
- One way would be to have a simple text component and an Add button. Use the
onActionPerformed
event to validate the data before adding it to a list custom property. Bind a label to the custom property to show the contents of the list. A problem with this approach is that there is no simple way to remove an item from the list.
- A table is probably a better solution. Ensure that there is always one blank row at the bottom, use the
onEditCellCommit
event to validate the data before updating the data source. The table gives you the option of adding a "Delete" column with a checkbox or button for each row.