Dropdown connected to table column?

Is it possible to connect the options on a dropdown menu to a specific column in a table on the page? I can add rows to my table and want to make sure that the dropdown menu will respond accordingly if changes are made.

In addition to this, could i also make a dropdown table that only showed certain rows based on a value in a certain column?

Both of these things are certainly doable. I assume you have a separate dropdown list control and aren’t talking about a dropdown embedded in your table.

In the property change event of your table

if event.propertyName == "data":

sort through the new table data and build a new dataset for your dropdown list control.

If you need help doing that, post what you have and I or someone else should be able to assist.

Yes, I’m referring to a dropdown menu separate from the table (not embedded into it). What do you need to see of mine in order to help? I can take screenshots if that’s what you need, or if you have some sort of ‘template’ text for me to look at, I could probably modify it for my needs.

One other thing I was looking into doing was creating a search bar so that I would be able to sift through rows if I had hundreds of them. Is a search functionality possible for a table?

Without knowing anything about your data the basic idea would be something like this:

if event.propertyName == "data":
	ddlData = []
	tableData = event.newValue
	for row in range(tableData.rowCount):
		new_row = []
		value = tableData.getValueAt(row, "columnOfInterest")
		if value not in ddlData:
			new_row.append([value, value])
	if len(ddlData) > 0:
		event.source.parent.getComonent("myDdlComponent").data = system.dataset.toDataSet(["Value","Label"],ddlData)

For the search function i would make a custom dataset property on the root container that holds the entire dataset. Then on the keyReleased event of your search textbox do something similar:

tableRows = []
searchText = event.newValue
headers = system.dataset.getColumnHeaders(event.newValue)
pyDs = system.dataset.toPyDataSet(event.source.parent.fullDataset)

for row in pyDs:
if searchText in row[“ColumnToSearch”]:
event.source.parent.getComponent(“myTable”).data = system.dataset.toDataSet(headers, tableRows)[/code]

These are not tested scripts but they should get you on the right path.

Hi alewayhar,

I need more information to understand exactly what you are trying to do with the dropdown and table.
A screen shot or further description would help.

Today a new Ignition module was released and one of the things it does is make working with Dataset easier and nicer. The module adds a MutablePyDataSet which is a new data type that has many methods for accessing and modifying data from a dataset.

Here is a solution for searching a table using a MutablePyDataSet.

Add a dataset custom property to the table called “AllData” that will hold all the data that will be searched. Add a text field to the window and make sure that the Defer Updates property of the text field is False. Then add the following propertyChange event script to the text field:

if event.propertyName == "text":
	searchText = event.newValue.lower()
	table = event.source.parent.getComponent('Table')
	allData = pa.dataset.toData(table.AllData)	
	rowsFound = allData.findRows(lambda row: searchText in row["Col 2"].lower())	
	table.data = rowsFound.toDataSet()

Notice that the findRows method is searching the dataset for specific rows by evaluating a function for each row. If the function returns true for a row then the row is included in the results. lambda is a way to define an anonymous function in a single line of code. Change “Col 2” to the column of the dataset that you want to search.

The new Ignition module that makes the MutablePyDataSet available is here: marketplace.inductiveautomation. … oduleId=87

Documentation for the MutablePyDataSet is here: doc.perfectabstractions.com/modu … taset.html


I realized the script I wrote above could be written in a single line of code. So for your entertainment:

if event.propertyName == "text": event.source.parent.getComponent('Table').data = pa.dataset.toData(event.source.parent.getComponent('Table').AllData).findRows(lambda row: event.newValue.lower() in row["Col 2"].lower()).toDataSet()

To make the code shorter but still readable this version works:

if event.propertyName == "text": 
	table = event.source.parent.getComponent('Table')
	table.data = pa.dataset.toData(table.AllData).findRows(lambda row: event.newValue.lower() in row["Col 2"].lower()).toDataSet()

[quote=“nmudge”]The new Ignition module that makes the MutablePyDataSet available is here: marketplace.inductiveautomation. … oduleId=87

Documentation for the MutablePyDataSet is here: doc.perfectabstractions.com/modu … taset.html[/quote]
Sweet! Especially the @run decorator!

pturmel, download it and have fun with it!

I know that this response is a few weeks late, but I just got back around to this and got to read a lot of these responses. My question is, is this objective with the dropdown menu possible without the mutablePyDataset? I see that the module costs to use, and it seems like there’s gotta be a way to do this without purchasing another module, right?

With all this in mind, can i connect the dropdown menu to the chart and vice versa? The dropdown menu getting it’s individual options from the Name column in the chart and then displaying all the rows with that name in said column. This is the correct way to go about this, right? Or is this not the way I should be approaching this problem?

Sorry for drudging this back up, but I got caught up in another project for a while there. :open_mouth:

Hi alewayhar,

If price is the problem for getting the Power Scripting module I can reduce the cost for you. I thought for most people that $200 would be no problem.

With a little Python scripting you can certainly do anything with datasets that MutablePyDataSet can. Learn Python, look at the available dataset scripting functions provided by Ignition.

The purpose of MutablePyDataSet is to make some things with datasets easier to read and write and faster to implement. Time is money so if something costs a little but saves time then it can be worth it.


Yeah, the cost is reasonable for sure, I’m just not looking to spend any money right now :slight_smile:

But just for clarification, a mutablePyDataset is basically a dataset, but it’s easier to manipulate?

Hi alewayhar,

I understand.

In some ways MutablePyDataSet is easier to manipulate. Ignition provides a lot of builtin scripting functions for manipulating datasets, and it is easy to manipulate datasets using those.

MutablePyDataSet has additional scripting functions to do more things. MutablePyDataSets are also mutable which allows the rows and values to be changed in place, which is nice and can make some things easier to do.

Here’s an article I wrote that looks at different kinds of datasets in Ignition:

Here’s the full documentation of MutablePyDataSet: doc.perfectabstractions.com/modu … taset.html


This could be done using the existing tools built into Ignition. The steps I would take to make this happen:

  1. Create a custom property of type dataset on your root container to hold all of your data. Fot this example I will call the dataset myDS.

  2. Add a SQL binding on your dropdown. In MSSQL it would be something like this:


(The SELECT 'None, ‘None’ provides a value that we can use to to know not to filter the data if the user wants to see it all.)

  1. Add some scripting to the propertyChanged event of your root container to initialize/update your table with the myDS data.

if event.propertyName == "myDS": event.source.getComponent("myTable").data = event.newValue

  1. Add script to your dropdown’s propertyChanged event t filter the full dataset (myDS) by the new value and update the table.

if event.propertyName == "selectedStringValue": table = event.source.getComponent("myTable") myDS = event.source.parent.myDS if event.newValue == "None": # Show all of the data table.data = myDS else: headers = system.dataset.getColumnHeaders(myDS) filter = event.newValue.lower() newRows = [] for row in range(myDS.rowCount): if str(myDS.getValueAt(row, "Name")).lower() == filter: matchRow = [] for col in range(len(headers)): matchRow.append(myDS.getValueAt(row, col)) newRows.append(matchRow) if len(newRows) > 0: table.data = system.dataset.toDataSet(headers, newRows)