I have placed dropdown box in ignition dashboard in which I have form 3 column named group 1, group 2, group 3, now I want that when I select one then subcomponent will get display in form of in another drop downlist so how can I do that?
First, add a custom property to the second dropdown called masterDataset
Add columns for value, and every other category
Populate it with all of the data.
When completed, it should look like this:
Finally, right click on the first dropdown, and select scripting:
Put a script into the propertyChange event handler that loops through and pulls out the data you want based upon the selection in the first dropdown:
# Check if the event's property name matches 'selectedLabel'.
# This prevents the script from firing when any of the other properties change
if event.propertyName == 'selectedLabel':
# Fetch the 'masterDataset' from the custom property on 'Dropdown 2'
masterData = event.source.parent.getComponent('Dropdown 2').masterDataset
# Define the column headers for the new dataset.
headers = ['Value', 'Label']
# Create a sublist by looping through each row of the masterData.
# For each row, we fetch 'value' and 'Type' columns. Only include rows where the 'Drink' column matches the new value of the event.
sublist = [[masterData.getValueAt(row, 'value'), masterData.getValueAt(row, 'Type')]
for row in range(masterData.rowCount)
if masterData.getValueAt(row, 'Drink') == event.newValue]
# Convert the created sublist into a dataset with the previously defined headers.
subData = system.dataset.toDataSet(headers, sublist)
# Update the 'data' property of the 'Dropdown 2' component with the newly created dataset.
event.source.parent.getComponent('Dropdown 2').data = subData
Result: